diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-03-12 22:25:46 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-03-20 23:44:59 +0800 |
| commit | 2ee35210b655bc9292cc32e4d5f3ac329836fd8a (patch) | |
| tree | 5cd63a60c12e4b1ad13d91b0084021ca7f2ca90b | |
| parent | 42365af64977554efa05699f08af8efb06c651b7 (diff) | |
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
| -rw-r--r-- | src/sessionManager.cpp | 8 |
1 files 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::pair<std::jthread, std::shared_ptr<CSes if (it != m_vSessions.end()) { if (it->first.joinable()) it->first.detach(); // .detach the thread since it's removing itself + it->second.reset(); m_vSessions.erase(it); } } |
