More timer cleanup.
This commit is contained in:
@@ -1011,7 +1011,7 @@ ClientStateWaitEnterLogin::Exit(boost::shared_ptr<ClientThread> client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientStateWaitEnterLogin::HandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket)
|
ClientStateWaitEnterLogin::HandlePacket(boost::shared_ptr<ClientThread> /*client*/, boost::shared_ptr<NetPacket> tmpPacket)
|
||||||
{
|
{
|
||||||
if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_errorMessage) {
|
if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_errorMessage) {
|
||||||
// Server reported an error.
|
// Server reported an error.
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ ServerLobbyThread::ServerLobbyThread(GuiInterface &gui, ServerMode mode, ServerI
|
|||||||
AvatarManager &avatarManager, boost::shared_ptr<boost::asio::io_service> ioService)
|
AvatarManager &avatarManager, boost::shared_ptr<boost::asio::io_service> ioService)
|
||||||
: m_ioService(ioService), m_authContext(NULL), m_gui(gui), m_ircBotCb(ircBotCb), m_avatarManager(avatarManager),
|
: m_ioService(ioService), m_authContext(NULL), m_gui(gui), m_ircBotCb(ircBotCb), m_avatarManager(avatarManager),
|
||||||
m_mode(mode), m_serverConfig(serverConfig), m_curGameId(0), m_curUniquePlayerId(0), m_curSessionId(INVALID_SESSION + 1),
|
m_mode(mode), m_serverConfig(serverConfig), m_curGameId(0), m_curUniquePlayerId(0), m_curSessionId(INVALID_SESSION + 1),
|
||||||
m_statDataChanged(false), m_removeGameTimer(*ioService), m_removePlayerTimer(*ioService),
|
m_statDataChanged(false), m_removeGameTimer(*ioService),
|
||||||
m_saveStatisticsTimer(*ioService), m_loginLockTimer(*ioService),
|
m_saveStatisticsTimer(*ioService), m_loginLockTimer(*ioService),
|
||||||
m_startTime(boost::posix_time::second_clock::local_time())
|
m_startTime(boost::posix_time::second_clock::local_time())
|
||||||
{
|
{
|
||||||
@@ -536,8 +536,7 @@ ServerLobbyThread::GetPlayerNameFromId(unsigned playerId) const
|
|||||||
void
|
void
|
||||||
ServerLobbyThread::RemovePlayer(unsigned playerId, unsigned errorCode)
|
ServerLobbyThread::RemovePlayer(unsigned playerId, unsigned errorCode)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_removePlayerListMutex);
|
m_ioService->post(boost::bind(&ServerLobbyThread::InternalRemovePlayer, shared_from_this(), playerId, errorCode));
|
||||||
m_removePlayerList.push_back(RemovePlayerList::value_type(playerId, errorCode));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -765,12 +764,6 @@ ServerLobbyThread::RegisterTimers()
|
|||||||
m_removeGameTimer.async_wait(
|
m_removeGameTimer.async_wait(
|
||||||
boost::bind(
|
boost::bind(
|
||||||
&ServerLobbyThread::TimerRemoveGame, shared_from_this(), boost::asio::placeholders::error));
|
&ServerLobbyThread::TimerRemoveGame, shared_from_this(), boost::asio::placeholders::error));
|
||||||
// Remove inactive/kicked players.
|
|
||||||
m_removePlayerTimer.expires_from_now(
|
|
||||||
boost::posix_time::milliseconds(SERVER_REMOVE_PLAYER_INTERVAL_MSEC));
|
|
||||||
m_removePlayerTimer.async_wait(
|
|
||||||
boost::bind(
|
|
||||||
&ServerLobbyThread::TimerRemovePlayer, shared_from_this(), boost::asio::placeholders::error));
|
|
||||||
// Update the statistics file.
|
// Update the statistics file.
|
||||||
m_saveStatisticsTimer.expires_from_now(
|
m_saveStatisticsTimer.expires_from_now(
|
||||||
boost::posix_time::seconds(SERVER_SAVE_STATISTICS_INTERVAL_SEC));
|
boost::posix_time::seconds(SERVER_SAVE_STATISTICS_INTERVAL_SEC));
|
||||||
@@ -789,7 +782,6 @@ void
|
|||||||
ServerLobbyThread::CancelTimers()
|
ServerLobbyThread::CancelTimers()
|
||||||
{
|
{
|
||||||
m_removeGameTimer.cancel();
|
m_removeGameTimer.cancel();
|
||||||
m_removePlayerTimer.cancel();
|
|
||||||
m_saveStatisticsTimer.cancel();
|
m_saveStatisticsTimer.cancel();
|
||||||
m_loginLockTimer.cancel();
|
m_loginLockTimer.cancel();
|
||||||
}
|
}
|
||||||
@@ -1643,31 +1635,6 @@ ServerLobbyThread::TimerRemoveGame(const boost::system::error_code &ec)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ServerLobbyThread::TimerRemovePlayer(const boost::system::error_code &ec)
|
|
||||||
{
|
|
||||||
if (!ec) {
|
|
||||||
boost::mutex::scoped_lock lock(m_removePlayerListMutex);
|
|
||||||
|
|
||||||
if (!m_removePlayerList.empty()) {
|
|
||||||
RemovePlayerList::iterator i = m_removePlayerList.begin();
|
|
||||||
RemovePlayerList::iterator end = m_removePlayerList.end();
|
|
||||||
|
|
||||||
while (i != end) {
|
|
||||||
InternalRemovePlayer(i->first, i->second);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
m_removePlayerList.clear();
|
|
||||||
}
|
|
||||||
// Restart timer
|
|
||||||
m_removePlayerTimer.expires_from_now(
|
|
||||||
boost::posix_time::milliseconds(SERVER_REMOVE_PLAYER_INTERVAL_MSEC));
|
|
||||||
m_removePlayerTimer.async_wait(
|
|
||||||
boost::bind(
|
|
||||||
&ServerLobbyThread::TimerRemovePlayer, shared_from_this(), boost::asio::placeholders::error));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerLobbyThread::TimerUpdateClientLoginLock(const boost::system::error_code &ec)
|
ServerLobbyThread::TimerUpdateClientLoginLock(const boost::system::error_code &ec)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -215,9 +215,6 @@ private:
|
|||||||
RemoveGameList m_removeGameList;
|
RemoveGameList m_removeGameList;
|
||||||
mutable boost::mutex m_removeGameListMutex;
|
mutable boost::mutex m_removeGameListMutex;
|
||||||
|
|
||||||
RemovePlayerList m_removePlayerList;
|
|
||||||
mutable boost::mutex m_removePlayerListMutex;
|
|
||||||
|
|
||||||
PlayerDataMap m_computerPlayers;
|
PlayerDataMap m_computerPlayers;
|
||||||
mutable boost::mutex m_computerPlayersMutex;
|
mutable boost::mutex m_computerPlayersMutex;
|
||||||
|
|
||||||
@@ -247,7 +244,6 @@ private:
|
|||||||
boost::shared_ptr<ServerDBInterface> m_database;
|
boost::shared_ptr<ServerDBInterface> m_database;
|
||||||
|
|
||||||
boost::asio::deadline_timer m_removeGameTimer;
|
boost::asio::deadline_timer m_removeGameTimer;
|
||||||
boost::asio::deadline_timer m_removePlayerTimer;
|
|
||||||
boost::asio::deadline_timer m_saveStatisticsTimer;
|
boost::asio::deadline_timer m_saveStatisticsTimer;
|
||||||
boost::asio::deadline_timer m_loginLockTimer;
|
boost::asio::deadline_timer m_loginLockTimer;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user