diff --git a/Services/RequestServer/ConnectionFromClient.cpp b/Services/RequestServer/ConnectionFromClient.cpp index 393e50a2889..6c90f3def1c 100644 --- a/Services/RequestServer/ConnectionFromClient.cpp +++ b/Services/RequestServer/ConnectionFromClient.cpp @@ -625,10 +625,12 @@ void ConnectionFromClient::check_active_requests() // FIXME: Come up with a unified way to track websockets and standard fetches instead of this nasty tagged pointer if (reinterpret_cast(application_private) & websocket_private_tag) { auto* websocket_impl = reinterpret_cast(reinterpret_cast(application_private) & ~websocket_private_tag); - if (msg->data.result == CURLE_OK) - websocket_impl->did_connect(); - else + if (msg->data.result == CURLE_OK) { + if (!websocket_impl->did_connect()) + websocket_impl->on_connection_error(); + } else { websocket_impl->on_connection_error(); + } continue; } diff --git a/Services/RequestServer/WebSocketImplCurl.cpp b/Services/RequestServer/WebSocketImplCurl.cpp index fa496738f48..b541374c1a2 100644 --- a/Services/RequestServer/WebSocketImplCurl.cpp +++ b/Services/RequestServer/WebSocketImplCurl.cpp @@ -160,11 +160,12 @@ void WebSocketImplCurl::discard_connection() } } -void WebSocketImplCurl::did_connect() +bool WebSocketImplCurl::did_connect() { curl_socket_t socket_fd = CURL_SOCKET_BAD; auto res = curl_easy_getinfo(m_easy_handle, CURLINFO_ACTIVESOCKET, &socket_fd); - VERIFY(res == CURLE_OK && socket_fd != CURL_SOCKET_BAD); + if (res != CURLE_OK || socket_fd == CURL_SOCKET_BAD) + return false; m_read_notifier = Core::Notifier::construct(socket_fd, Core::Notifier::Type::Read); m_read_notifier->on_activation = [this] { @@ -190,6 +191,7 @@ void WebSocketImplCurl::did_connect() }; on_connected(); + return true; } } diff --git a/Services/RequestServer/WebSocketImplCurl.h b/Services/RequestServer/WebSocketImplCurl.h index 1ee959781a9..25f0500e5bc 100644 --- a/Services/RequestServer/WebSocketImplCurl.h +++ b/Services/RequestServer/WebSocketImplCurl.h @@ -29,7 +29,7 @@ public: virtual bool handshake_complete_when_connected() const override { return true; } - void did_connect(); + bool did_connect(); private: explicit WebSocketImplCurl(CURLM*);