diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-29 18:42:01 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-30 23:34:40 +0100 |
commit | fe003939413d0de648618e2cd5f5c72182c7cf7b (patch) | |
tree | e75b7e24ca4df39d07a4cc23af30a47ee87bd9c3 /Userland/Libraries/LibCore/LocalServer.cpp | |
parent | 6cb3092b42132ab8ff59158e0b418a818c7ec315 (diff) | |
download | serenity-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.cpp | 6 |
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()); + } }; } |