From 64e231bd389e0ac3afe72bf8189c703cabee8546 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Mon, 4 Oct 2021 15:14:36 +0330 Subject: LibHTTP+LibGemini: Set underlying sockets as idle when detaching This ultimately makes the sockets not spin while unused (particularly in the 10s shutdown period that RequestServer's cache has). --- Userland/Libraries/LibGemini/GeminiJob.cpp | 2 ++ Userland/Libraries/LibHTTP/HttpJob.cpp | 2 ++ Userland/Libraries/LibHTTP/HttpsJob.cpp | 2 ++ 3 files changed, 6 insertions(+) (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibGemini/GeminiJob.cpp b/Userland/Libraries/LibGemini/GeminiJob.cpp index b459d81afd..57cde2260f 100644 --- a/Userland/Libraries/LibGemini/GeminiJob.cpp +++ b/Userland/Libraries/LibGemini/GeminiJob.cpp @@ -42,6 +42,7 @@ void GeminiJob::start(NonnullRefPtr socket) on_certificate_requested(*this); }; + m_socket->set_idle(false); if (m_socket->is_established()) { deferred_invoke([this] { on_socket_connected(); }); } else { @@ -67,6 +68,7 @@ void GeminiJob::shutdown(ShutdownMode mode) } else { m_socket->on_tls_ready_to_read = nullptr; m_socket->on_tls_connected = nullptr; + m_socket->set_idle(true); m_socket = nullptr; } } diff --git a/Userland/Libraries/LibHTTP/HttpJob.cpp b/Userland/Libraries/LibHTTP/HttpJob.cpp index 6e0115c341..dd3cb69584 100644 --- a/Userland/Libraries/LibHTTP/HttpJob.cpp +++ b/Userland/Libraries/LibHTTP/HttpJob.cpp @@ -22,6 +22,7 @@ void HttpJob::start(NonnullRefPtr socket) did_fail(Core::NetworkJob::Error::ConnectionFailed); }); }; + m_socket->set_idle(false); if (m_socket->is_connected()) { dbgln("Reusing previous connection for {}", url()); deferred_invoke([this] { @@ -52,6 +53,7 @@ void HttpJob::shutdown(ShutdownMode mode) } else { m_socket->on_ready_to_read = nullptr; m_socket->on_connected = nullptr; + m_socket->set_idle(true); m_socket = nullptr; } } diff --git a/Userland/Libraries/LibHTTP/HttpsJob.cpp b/Userland/Libraries/LibHTTP/HttpsJob.cpp index cadfbea933..3464527590 100644 --- a/Userland/Libraries/LibHTTP/HttpsJob.cpp +++ b/Userland/Libraries/LibHTTP/HttpsJob.cpp @@ -43,6 +43,7 @@ void HttpsJob::start(NonnullRefPtr socket) if (on_certificate_requested) on_certificate_requested(*this); }; + m_socket->set_idle(false); if (m_socket->is_established()) { dbgln("Reusing previous connection for {}", url()); deferred_invoke([this] { on_socket_connected(); }); @@ -72,6 +73,7 @@ void HttpsJob::shutdown(ShutdownMode mode) m_socket->on_tls_ready_to_read = nullptr; m_socket->on_tls_connected = nullptr; m_socket->set_on_tls_ready_to_write(nullptr); + m_socket->set_idle(true); m_socket = nullptr; } } -- cgit v1.2.3