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 | |
| 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')
| -rw-r--r-- | src/sessionManager.cpp | 4 | ||||
| -rw-r--r-- | src/sessionManager.hpp | 4 |
2 files changed, 4 insertions, 4 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()) { diff --git a/src/sessionManager.hpp b/src/sessionManager.hpp index 4ca3311..9739918 100644 --- a/src/sessionManager.hpp +++ b/src/sessionManager.hpp @@ -16,8 +16,8 @@ class CSessionManager { void run(); void broadcast(const std::string &msg) const; - void kick(CSession *session, const bool &kill = false, const std::string &reason = ""); - void kick(std::pair<std::jthread, std::shared_ptr<CSession>> *session, const bool &kill = false, const std::string &reason = ""); + void kick(CSession *session, const bool kill = false, const std::string &reason = ""); + void kick(std::pair<std::jthread, std::shared_ptr<CSession>> *session, const bool kill = false, const std::string &reason = ""); void addSession(const CSession &session); bool nameExists(const std::string &name); |
