diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-03-21 13:58:21 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-03-22 15:02:46 +0800 |
| commit | 97d82139d2011a790c0d3d254add5d800de2742f (patch) | |
| tree | 3763e89292c0fd4a8af5c7b7373f014826c4411f /src/sessionManager.cpp | |
| parent | d6ef0dfafde7148a29d2e892932d4aa338ab9c7c (diff) | |
fix(sessionManager,kick): only write message if CSession exist
Diffstat (limited to 'src/sessionManager.cpp')
| -rw-r--r-- | src/sessionManager.cpp | 5 |
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 |
