LibWebSocket: Ensure TLS connection is opened as non-blocking

This commit is contained in:
devgianlu 2025-02-22 13:02:52 +01:00 committed by Ali Mohammad Pur
parent 85d46a71d9
commit 752f5b18fd
Notes: github-actions[bot] 2025-02-22 17:41:15 +00:00

View file

@ -47,13 +47,15 @@ void WebSocketImplSerenity::connect(ConnectionInfo const& connection_info)
if (connection_info.is_secure()) {
TLS::Options options;
options.set_root_certificates_path(connection_info.root_certificates_path());
options.set_blocking(false);
return TRY(Core::BufferedSocket<TLS::TLSv12>::create(
TRY(TLS::TLSv12::connect(host, connection_info.url().port_or_default(), move(options)))));
}
return TRY(Core::BufferedTCPSocket::create(
TRY(Core::TCPSocket::connect(host, connection_info.url().port_or_default()))));
auto tcp_socket = TRY(Core::TCPSocket::connect(host, connection_info.url().port_or_default()));
TRY(tcp_socket->set_blocking(false));
return TRY(Core::BufferedTCPSocket::create(move(tcp_socket)));
}();
if (socket_result.is_error()) {
@ -64,8 +66,6 @@ void WebSocketImplSerenity::connect(ConnectionInfo const& connection_info)
}
m_socket = socket_result.release_value();
MUST(m_socket->set_blocking(false));
m_socket->on_ready_to_read = [this] {
on_ready_to_read();
};