summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-03-21 13:58:21 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-03-22 15:02:46 +0800
commit97d82139d2011a790c0d3d254add5d800de2742f (patch)
tree3763e89292c0fd4a8af5c7b7373f014826c4411f /src
parentd6ef0dfafde7148a29d2e892932d4aa338ab9c7c (diff)
fix(sessionManager,kick): only write message if CSession exist
Diffstat (limited to 'src')
-rw-r--r--src/sessionManager.cpp5
1 files changed, 2 insertions, 3 deletions
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<std::jthread, std::shared_ptr<CSession>> *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