Canceling asio timers has bad semantics, and causes loads of trouble. Therefore, cancelled timers are simply marked as such, and the asio callback is silently ignored. This fixes several crashes, if players were removed from a game due to an error, because some timers were not cancelled. *sigh* This one took a lot of nerve.

This commit is contained in:
lotodore
2009-06-07 23:25:13 +00:00
parent a6146399d4
commit c8594e8e7b
10 changed files with 56 additions and 44 deletions
+6 -5
View File
@@ -563,7 +563,7 @@ ServerLobbyThread::RegisterTimers()
}
void
ServerLobbyThread::HandleRead(SessionId sessionId, const boost::system::error_code& error, size_t bytesRead)
ServerLobbyThread::HandleRead(SessionId sessionId, const boost::system::error_code &error, size_t bytesRead)
{
// Find the session.
SessionWrapper session = m_sessionManager.GetSessionById(sessionId);
@@ -949,11 +949,11 @@ ServerLobbyThread::HandleNetPacketCreateGame(SessionWrapper session, const NetPa
session.playerData->GetUniqueId(),
GetGui(),
m_playerConfig));
MoveSessionToGame(*game, session);
game->Init();
// Add game to list of games.
InternalAddGame(game);
MoveSessionToGame(*game, session);
}
void
@@ -1043,7 +1043,7 @@ ServerLobbyThread::TimerRemoveGame()
++next;
boost::shared_ptr<ServerGame> tmpGame = i->second;
if (!tmpGame->GetSessionManager().HasSessions())
InternalRemoveGame(tmpGame); // This will delete the entry from the map.
InternalRemoveGame(tmpGame); // This will delete the game.
i = next;
}
}
@@ -1154,6 +1154,7 @@ ServerLobbyThread::InternalRemoveGame(boost::shared_ptr<ServerGame> game)
// Remove all sessions left in the game.
game->ResetComputerPlayerList();
game->RemoveAllSessions();
game->Exit();
// Notify all players.
boost::shared_ptr<NetPacket> packet = CreateNetPacketGameListUpdate(game->GetId(), GAME_MODE_CLOSED);
m_sessionManager.SendLobbyMsgToAllSessions(GetSender(), packet, SessionData::Established);