diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-03-21 21:19:31 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-03-22 15:02:46 +0800 |
| commit | ee63886625aef473a177ad4728eeb5784ffbe159 (patch) | |
| tree | 39378372b9e6614dd6eb758123be77f9ed4fca06 /src/sessionManager.cpp | |
| parent | 8830ac37d72fa3465afdbd05e5d0176f0859eb97 (diff) | |
fix: potential crash for weirdly exited clients
fixes #9
FIXME: spamming too much will still give
```
terminate called after throwing an instance of 'std::system_error'
what(): Resource deadlock avoided
```
Diffstat (limited to 'src/sessionManager.cpp')
| -rw-r--r-- | src/sessionManager.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/sessionManager.cpp b/src/sessionManager.cpp index 0e27367..cb8a2d4 100644 --- a/src/sessionManager.cpp +++ b/src/sessionManager.cpp @@ -72,13 +72,13 @@ std::vector<std::shared_ptr<CSession>> CSessionManager::getSessions() const { return m_vSessions | std::views::transform([](const auto &s) { return s.second; }) | std::ranges::to<std::vector>(); } -void CSessionManager::kick(CSession *session, const bool &kill, const std::string &reason) { +void CSessionManager::kick(CSession *session, const bool kill, const std::string &reason) { for (auto &_session : m_vSessions) if (_session.second.get() == session) kick(&_session, kill, reason); } -void CSessionManager::kick(std::pair<std::jthread, std::shared_ptr<CSession>> *session, const bool &kill, const std::string &reason) { +void CSessionManager::kick(std::pair<std::jthread, std::shared_ptr<CSession>> *session, const bool kill, const std::string &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()) { |
