mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 03:28:13 +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
|
@ -34,15 +34,11 @@ int main(int, char**)
|
|||
auto server = Core::LocalServer::construct();
|
||||
bool ok = server->take_over_from_system_server();
|
||||
VERIFY(ok);
|
||||
server->on_ready_to_accept = [&] {
|
||||
auto client_socket = server->accept();
|
||||
if (!client_socket) {
|
||||
dbgln("AudioServer: accept failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
server->on_accept = [&](NonnullRefPtr<Core::LocalSocket> client_socket) {
|
||||
static int s_next_client_id = 0;
|
||||
int client_id = ++s_next_client_id;
|
||||
IPC::new_client_connection<AudioServer::ClientConnection>(client_socket.release_nonnull(), client_id, *mixer);
|
||||
IPC::new_client_connection<AudioServer::ClientConnection>(move(client_socket), client_id, *mixer);
|
||||
};
|
||||
|
||||
if (pledge("stdio recvfd thread accept cpath rpath wpath", nullptr) < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue