diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-13 13:47:01 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-13 13:47:01 +0200 |
commit | 4ab1b0b43681323e5d0e6b0572781ff70ab74a15 (patch) | |
tree | 8a94c5252b0957902f13a7f7031bc404765ed46f | |
parent | 47df0cbbc82778beaa12f4b5f84f924c32ce2c60 (diff) | |
download | serenity-4ab1b0b43681323e5d0e6b0572781ff70ab74a15.zip |
LibIPC: Only start responsiveness timer after sending client a message
Instead of always running the responsiveness timer for IPC clients,
we now only start it after sending a message. This avoids waking up
otherwise idle clients to do ping/pong busywork.
-rw-r--r-- | Libraries/LibIPC/ClientConnection.h | 9 | ||||
-rw-r--r-- | Services/WindowServer/ClientConnection.cpp | 5 | ||||
-rw-r--r-- | Services/WindowServer/ClientConnection.h | 1 |
3 files changed, 13 insertions, 2 deletions
diff --git a/Libraries/LibIPC/ClientConnection.h b/Libraries/LibIPC/ClientConnection.h index 429958e644..516fb7c0e0 100644 --- a/Libraries/LibIPC/ClientConnection.h +++ b/Libraries/LibIPC/ClientConnection.h @@ -101,6 +101,7 @@ public: } virtual void may_have_become_unresponsive() {} + virtual void did_become_responsive() {} void post_message(const Message& message) { @@ -130,6 +131,8 @@ public: } ASSERT(static_cast<size_t>(nwritten) == buffer.size()); + + m_responsiveness_timer->start(); } void drain_messages_from_client() @@ -156,8 +159,10 @@ public: bytes.append(buffer, nread); } - if (!bytes.is_empty()) - m_responsiveness_timer->restart(); + if (!bytes.is_empty()) { + m_responsiveness_timer->stop(); + did_become_responsive(); + } size_t decoded_bytes = 0; for (size_t index = 0; index < bytes.size(); index += decoded_bytes) { diff --git a/Services/WindowServer/ClientConnection.cpp b/Services/WindowServer/ClientConnection.cpp index dff7ae8d51..56353cda36 100644 --- a/Services/WindowServer/ClientConnection.cpp +++ b/Services/WindowServer/ClientConnection.cpp @@ -844,4 +844,9 @@ void ClientConnection::may_have_become_unresponsive() }); } +void ClientConnection::did_become_responsive() +{ + set_unresponsive(false); +} + } diff --git a/Services/WindowServer/ClientConnection.h b/Services/WindowServer/ClientConnection.h index b662d31110..ea4d822d55 100644 --- a/Services/WindowServer/ClientConnection.h +++ b/Services/WindowServer/ClientConnection.h @@ -89,6 +89,7 @@ private: // ^ClientConnection virtual void die() override; virtual void may_have_become_unresponsive() override; + virtual void did_become_responsive() override; void set_unresponsive(bool); void destroy_window(Window&, Vector<i32>& destroyed_window_ids); |