File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -73,21 +73,19 @@ void ClientManager::kill_all() {
7373
7474
7575void ClientManager::reap_dead_client_connections () {
76- auto lambda_kill_client_if_dead = [](ClientConnection* client) {
76+ auto lambda_kill_and_delete_client_if_dead = [](ClientConnection* client) {
7777 if (!client->is_connection_alive ()) {
7878 client->kill ();
7979 client->stop ();
8080 client->join ();
81+ delete client;
8182 return true ;
8283 }
8384 return false ;
8485 };
8586
86- auto dead_clients_iterator =
87- std::remove_if (this ->clients .begin (), this ->clients .end (), lambda_kill_client_if_dead);
88-
89- auto lambda_clean_client_memory = [](ClientConnection* client) { delete client; };
90- std::for_each (dead_clients_iterator, this ->clients .end (), lambda_clean_client_memory);
87+ auto dead_clients_iterator = std::remove_if (this ->clients .begin (), this ->clients .end (),
88+ lambda_kill_and_delete_client_if_dead);
9189
9290 this ->clients .erase (dead_clients_iterator, this ->clients .end ());
9391}
You can’t perform that action at this time.
0 commit comments