From 48589db3aab2085ec4e5729fcf8f1a4a8a66067f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 13 Dec 2020 19:15:42 +0100 Subject: [PATCH] Kernel/Net: Socket connected state change should reevaluate blocks This fixes an issue where TCP sockets could get into the Established state too quickly and fail to unblock a subsequent sys$select() call. This makes websites load *significantly* faster. :^) --- Kernel/Net/Socket.cpp | 9 +++++++++ Kernel/Net/Socket.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp index 7b6cd51a5c..4aeccb254b 100644 --- a/Kernel/Net/Socket.cpp +++ b/Kernel/Net/Socket.cpp @@ -269,4 +269,13 @@ KResult Socket::stat(::stat& st) const return KSuccess; } +void Socket::set_connected(bool connected) +{ + LOCKER(lock()); + if (m_connected == connected) + return; + m_connected = connected; + evaluate_block_conditions(); +} + } diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h index 4aa4a4920d..9116617bb1 100644 --- a/Kernel/Net/Socket.h +++ b/Kernel/Net/Socket.h @@ -91,7 +91,7 @@ public: virtual Role role(const FileDescription&) const { return m_role; } bool is_connected() const { return m_connected; } - void set_connected(bool connected) { m_connected = connected; } + void set_connected(bool); bool can_accept() const { return !m_pending.is_empty(); } RefPtr accept();