summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore/LocalServer.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-29 18:42:01 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-30 23:34:40 +0100
commitfe003939413d0de648618e2cd5f5c72182c7cf7b (patch)
treee75b7e24ca4df39d07a4cc23af30a47ee87bd9c3 /Userland/Libraries/LibCore/LocalServer.cpp
parent6cb3092b42132ab8ff59158e0b418a818c7ec315 (diff)
downloadserenity-fe003939413d0de648618e2cd5f5c72182c7cf7b.zip
LibCore: Change Core::LocalServer::on_ready_to_accept => on_accept
Everyone used this hook in the same way: immediately accept() on the socket and then do something with the newly accepted fd. This patch simplifies the hook by having LocalServer do the accepting automatically.
Diffstat (limited to 'Userland/Libraries/LibCore/LocalServer.cpp')
-rw-r--r--Userland/Libraries/LibCore/LocalServer.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Libraries/LibCore/LocalServer.cpp b/Userland/Libraries/LibCore/LocalServer.cpp
index 2f423a56f5..d1362b41ef 100644
--- a/Userland/Libraries/LibCore/LocalServer.cpp
+++ b/Userland/Libraries/LibCore/LocalServer.cpp
@@ -83,8 +83,10 @@ void LocalServer::setup_notifier()
{
m_notifier = Notifier::construct(m_fd, Notifier::Event::Read, this);
m_notifier->on_ready_to_read = [this] {
- if (on_ready_to_accept)
- on_ready_to_accept();
+ if (on_accept) {
+ if (auto client_socket = accept())
+ on_accept(client_socket.release_nonnull());
+ }
};
}