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
commit fe00393941
Notes: sideshowbarker 2024-07-17 23:17:22 +09:00
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());
}
};
}