1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix connection termination handling

This commit is contained in:
Ivan Savenko 2024-05-13 14:09:59 +00:00
parent 2bb96018b8
commit 93038b791e
3 changed files with 7 additions and 4 deletions

View File

@ -913,7 +913,6 @@ void CServerHandler::onDisconnected(const std::shared_ptr<INetworkConnection> &
if(getState() == EClientState::DISCONNECTING)
{
assert(networkConnection == nullptr);
// Note: this branch can be reached on app shutdown, when main thread holds mutex till destruction
logNetwork->info("Successfully closed connection to server!");
return;

View File

@ -49,9 +49,11 @@ void NetworkServer::connectionAccepted(std::shared_ptr<NetworkSocket> upcomingCo
void NetworkServer::onDisconnected(const std::shared_ptr<INetworkConnection> & connection, const std::string & errorMessage)
{
logNetwork->info("Connection lost! Reason: %s", errorMessage);
assert(connections.count(connection));
connections.erase(connection);
listener.onDisconnected(connection, errorMessage);
if (connections.count(connection))
{
connections.erase(connection);
listener.onDisconnected(connection, errorMessage);
}
}
void NetworkServer::onPacketReceived(const std::shared_ptr<INetworkConnection> & connection, const std::vector<std::byte> & message)

View File

@ -51,6 +51,8 @@ void GlobalLobbyProcessor::onDisconnected(const std::shared_ptr<INetworkConnecti
message["accountID"].String() = proxy.first;
sendMessage(controlConnection, message);
proxyConnections.erase(proxy.first);
break;
}
}