From 2ee35210b655bc9292cc32e4d5f3ac329836fd8a Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 12 Mar 2025 22:25:46 +0800 Subject: fix(sessionManager): don't join() thread on dtor, reset them instead also do that in removeSession this fixes when theres multiple clients, the first join() would block second one from getting destoryed --- src/sessionManager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sessionManager.cpp b/src/sessionManager.cpp index f5b29af..85263f1 100644 --- a/src/sessionManager.cpp +++ b/src/sessionManager.cpp @@ -18,10 +18,11 @@ CSessionManager::CSessionManager() { }; CSessionManager::~CSessionManager() { - for (auto &[thread, session] : m_vSessions) + for (auto &[thread, session] : m_vSessions) { if (thread.joinable()) - thread.join(); - + thread.detach(); + session.reset(); + } log(SYS, "SessionManager: bye"); } @@ -62,6 +63,7 @@ void CSessionManager::removeSession(std::pairfirst.joinable()) it->first.detach(); // .detach the thread since it's removing itself + it->second.reset(); m_vSessions.erase(it); } } -- cgit v1.2.3