diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-06-28 17:09:13 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-06-28 17:09:13 +1000 |
commit | bb5387fbdb90ec5e3b387ed73718b281b207252b (patch) | |
tree | 31e7bf187b8c1eeb85fa92906b3eb24c3830367d /source/game/StarUniverseServer.cpp | |
parent | 4120a289dbd98df956259dd3d0be2219b40b5fa5 (diff) |
fix seemingly extremely rare race condition leading to exception when joining a singleplayer internal server
happened when the client thread called universeServer->setPause (which locks m_clientsLock) between the client id being added to m_clients and the connection being added to m_connectionServer
Diffstat (limited to 'source/game/StarUniverseServer.cpp')
-rw-r--r-- | source/game/StarUniverseServer.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/source/game/StarUniverseServer.cpp b/source/game/StarUniverseServer.cpp index 7317e52..2bc2c45 100644 --- a/source/game/StarUniverseServer.cpp +++ b/source/game/StarUniverseServer.cpp @@ -1679,6 +1679,7 @@ void UniverseServer::acceptConnection(UniverseConnection connection, Maybe<HostA auto clientContext = make_shared<ServerClientContext>(clientId, remoteAddress, clientConnect->playerUuid, clientConnect->playerName, clientConnect->playerSpecies, administrator, clientConnect->shipChunks); m_clients.add(clientId, clientContext); + m_connectionServer->addConnection(clientId, std::move(connection)); clientsLocker.unlock(); clientContext->registerRpcHandlers(m_teamManager->rpcHandlers()); @@ -1700,8 +1701,6 @@ void UniverseServer::acceptConnection(UniverseConnection connection, Maybe<HostA clientContext->setAdmin(false); clientContext->setShipUpgrades(clientConnect->shipUpgrades); - - m_connectionServer->addConnection(clientId, std::move(connection)); m_chatProcessor->connectClient(clientId, clientConnect->playerName); m_connectionServer->sendPackets(clientId, { |