summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-10-04 15:14:36 +0330
committerAndreas Kling <kling@serenityos.org>2021-10-04 15:31:26 +0200
commit64e231bd389e0ac3afe72bf8189c703cabee8546 (patch)
tree4369825cdfcd256123e65f01f3ce75fb5968b05d /Userland/Libraries
parent29acb7fcf8993d96d7c776d6e60dbb7464d8ebad (diff)
downloadserenity-64e231bd389e0ac3afe72bf8189c703cabee8546.zip
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).
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGemini/GeminiJob.cpp2
-rw-r--r--Userland/Libraries/LibHTTP/HttpJob.cpp2
-rw-r--r--Userland/Libraries/LibHTTP/HttpsJob.cpp2
3 files changed, 6 insertions, 0 deletions
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<Core::Socket> 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<Core::Socket> 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<Core::Socket> 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;
}
}