mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
EchoServer: Defer removal of client from clients HashMap
This is necessary to avoid trying to destruct the on_ready_to_read function from inside the function.
This commit is contained in:
parent
f4c181da9d
commit
1d03f62444
1 changed files with 4 additions and 2 deletions
|
@ -62,8 +62,10 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto client = Client::create(id, move(client_socket));
|
auto client = Client::create(id, move(client_socket));
|
||||||
client->on_exit = [&clients, id] {
|
client->on_exit = [&clients, id] {
|
||||||
|
Core::deferred_invoke([&clients, id] {
|
||||||
clients.remove(id);
|
clients.remove(id);
|
||||||
outln("Client {} disconnected", id);
|
outln("Client {} disconnected", id);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
clients.set(id, client);
|
clients.set(id, client);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue