mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:58:12 +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:
parent
6cb3092b42
commit
fe00393941
11 changed files with 28 additions and 80 deletions
|
@ -37,15 +37,10 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
|
|||
bool ok = server->take_over_from_system_server();
|
||||
VERIFY(ok);
|
||||
|
||||
server->on_ready_to_accept = [&] {
|
||||
auto client_socket = server->accept();
|
||||
if (!client_socket) {
|
||||
dbgln("SQLServer: 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<SQLServer::ClientConnection>(client_socket.release_nonnull(), client_id);
|
||||
IPC::new_client_connection<SQLServer::ClientConnection>(client_socket, client_id);
|
||||
};
|
||||
|
||||
return event_loop.exec();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue