1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-21 00:19:29 +02:00

Merge pull request #3973 from vcmi/master

Merge master -> beta
This commit is contained in:
Ivan Savenko
2024-05-14 16:59:10 +03:00
committed by GitHub
17 changed files with 116 additions and 53 deletions

View File

@ -119,7 +119,10 @@ CServerHandler::~CServerHandler()
if (serverRunner)
serverRunner->wait();
serverRunner.reset();
threadNetwork.join();
{
auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex);
threadNetwork.join();
}
}
catch (const std::runtime_error & e)
{
@ -421,6 +424,7 @@ void CServerHandler::sendClientDisconnecting()
networkConnection->close();
networkConnection.reset();
logicConnection.reset();
waitForServerShutdown();
}
void CServerHandler::setCampaignState(std::shared_ptr<CampaignState> newCampaign)
@ -901,6 +905,8 @@ void CServerHandler::onPacketReceived(const std::shared_ptr<INetworkConnection>
void CServerHandler::onDisconnected(const std::shared_ptr<INetworkConnection> & connection, const std::string & errorMessage)
{
boost::mutex::scoped_lock interfaceLock(GH.interfaceMutex);
if (connection != networkConnection)
{
// ServerHandler already closed this connection on its own
@ -918,8 +924,6 @@ void CServerHandler::onDisconnected(const std::shared_ptr<INetworkConnection> &
return;
}
boost::mutex::scoped_lock interfaceLock(GH.interfaceMutex);
logNetwork->error("Lost connection to server! Connection has been closed");
if(client)
@ -954,7 +958,6 @@ void CServerHandler::waitForServerShutdown()
}
else
{
boost::mutex::scoped_lock interfaceLock(GH.interfaceMutex);
if (getState() == EClientState::CONNECTING)
{
showServerError(CGI->generaltexth->translate("vcmi.server.errors.existingProcess"));