From f4c181da9dfd27bf0686fcfe10593e6d0f70cbd7 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Sat, 23 Oct 2021 11:47:34 +0000 Subject: [PATCH] TelnetServer: 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. --- Userland/Services/TelnetServer/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Services/TelnetServer/main.cpp b/Userland/Services/TelnetServer/main.cpp index 663a07b4e5..c2771048d2 100644 --- a/Userland/Services/TelnetServer/main.cpp +++ b/Userland/Services/TelnetServer/main.cpp @@ -135,7 +135,9 @@ int main(int argc, char** argv) run_command(ptm_fd, command); auto client = Client::create(id, move(client_socket), ptm_fd); - client->on_exit = [&clients, id] { clients.remove(id); }; + client->on_exit = [&clients, id] { + Core::deferred_invoke([&clients, id] { clients.remove(id); }); + }; clients.set(id, client); };