1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 17:28:11 +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

@ -20,15 +20,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool ok = server->take_over_from_system_server();
VERIFY(ok);
server->on_ready_to_accept = [&] {
auto client_socket = server->accept();
if (!client_socket) {
dbgln("NotificationServer: accept failed.");
return;
}
server->on_accept = [&](auto client_socket) {
static int s_next_client_id = 0;
int client_id = ++s_next_client_id;
IPC::new_client_connection<NotificationServer::ClientConnection>(client_socket.release_nonnull(), client_id);
IPC::new_client_connection<NotificationServer::ClientConnection>(move(client_socket), client_id);
};
TRY(Core::System::unveil("/res", "r"));