From 97d82139d2011a790c0d3d254add5d800de2742f Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Fri, 21 Mar 2025 13:58:21 +0800 Subject: fix(sessionManager,kick): only write message if CSession exist --- src/sessionManager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/sessionManager.cpp') diff --git a/src/sessionManager.cpp b/src/sessionManager.cpp index 801d9a7..51bede4 100644 --- a/src/sessionManager.cpp +++ b/src/sessionManager.cpp @@ -80,12 +80,11 @@ void CSessionManager::kick(CSession *session, const bool &kill, const std::strin } void CSessionManager::kick(std::pair> *session, const bool &kill, const std::string &reason) { - if (!reason.empty()) - session->second->write(reason); - auto it = std::ranges::find_if(m_vSessions, [session](const auto &s) { return s.second.get() == session->second.get(); }); if (it != m_vSessions.end()) { + if (!reason.empty()) + it->second->write(reason); const auto native_handle = it->first.native_handle(); if (it->first.joinable()) it->first.detach(); // .detach the thread since it's removing itself -- cgit v1.2.3