fix race on disconnect

between the time we check for `is_open` and the actual disconnect, the
socket could already have been disconnected by another thread (TOCTOU).
Furthermore, the disconnects can race causing a segfault or similar
issue in the asio's internals.
This commit is contained in:
Lion Kortlepel
2026-04-10 18:09:57 +02:00
parent e9ce71d39a
commit 7089e5da9a
5 changed files with 29 additions and 9 deletions
+1 -1
View File
@@ -224,7 +224,7 @@ void TServer::GlobalParser(const std::weak_ptr<TClient>& Client, std::vector<uin
case 'p':
if (!Network.Respond(*LockedClient, StringToVector("p"), false)) {
// failed to send
LockedClient->Disconnect("Failed to send ping");
Network.DisconnectClient(*LockedClient, "Failed to send ping");
} else {
Network.UpdatePlayer(*LockedClient);
}