1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 10:47:44 +00:00

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.
This commit is contained in:
Andreas Kling 2021-11-29 18:42:01 +01:00
parent 6cb3092b42
commit fe00393941
11 changed files with 28 additions and 80 deletions

View file

@ -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());
}
};
}