From 3e908e2b2b9fdf1988d97d97cdb3a52397772fa8 Mon Sep 17 00:00:00 2001 From: Alexey Ozeritskiy Date: Sat, 16 Dec 2023 23:38:12 +0100 Subject: [PATCH] Remove client node from Nodes on connection close --- src/server.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server.cpp b/src/server.cpp index df7a634..eb6a389 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -114,8 +114,9 @@ NNet::TVoidSuspendedTask TNode::DoConnect() { template NNet::TVoidTask TRaftServer::InboundConnection(TSocket socket) { + std::shared_ptr> client; try { - auto client = std::make_shared>( + client = std::make_shared>( "client", std::move(socket), TimeSource ); Nodes.insert(client); @@ -128,6 +129,7 @@ NNet::TVoidTask TRaftServer::InboundConnection(TSocket socket) { } catch (const std::exception & ex) { std::cerr << "Exception: " << ex.what() << "\n"; } + Nodes.erase(client); co_return; }