From f821f9c0a472b7b14da4efbde09652e6c83d38a4 Mon Sep 17 00:00:00 2001 From: lotodore Date: Sun, 28 Oct 2007 15:21:24 +0000 Subject: [PATCH] No longer delay closing of sessions (not needed any more). --- src/net/common/serverlobbythread.cpp | 34 ++++------------------------ src/net/serverlobbythread.h | 6 +---- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index bf970f3d..68f9beb2 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -30,7 +30,6 @@ #include -#define SERVER_CLOSE_SESSION_DELAY_SEC 1 #define SERVER_MAX_NUM_SESSIONS 512 // Maximum number of idle users in lobby. #define SERVER_CACHE_CLEANUP_INTERVAL_SEC 86400 // 1 day #define SERVER_INIT_SESSION_TIMEOUT_SEC 20 @@ -116,24 +115,16 @@ void ServerLobbyThread::RemoveSessionFromGame(SessionWrapper session) { // Just remove the session. Only for fatal errors. - m_gameSessionManager.RemoveSession(session.sessionData->GetId()); - // Update stats (if needed). - BroadcastStatisticsUpdate(); + CloseSession(session); } void -ServerLobbyThread::CloseSessionDelayed(SessionWrapper session) +ServerLobbyThread::CloseSession(SessionWrapper session) { m_initTimerSessionMap.erase(session.sessionData->GetId()); m_sessionManager.RemoveSession(session.sessionData->GetId()); m_gameSessionManager.RemoveSession(session.sessionData->GetId()); - boost::timers::portable::microsec_timer closeTimer; - CloseSessionList::value_type closeSessionData(closeTimer, session.sessionData); - - boost::mutex::scoped_lock lock(m_closeSessionListMutex); - m_closeSessionList.push_back(closeSessionData); - // Update stats (if needed). BroadcastStatisticsUpdate(); } @@ -299,10 +290,7 @@ ServerLobbyThread::ProcessLoop() } catch (const NetException &) { // On error: Close this session. - m_initTimerSessionMap.erase(session.sessionData->GetId()); - m_sessionManager.RemoveSession(session.sessionData->GetId()); - // Update stats (if needed). - BroadcastStatisticsUpdate(); + CloseSession(session); return; } if (packet.get()) @@ -702,20 +690,6 @@ ServerLobbyThread::CloseSessionLoop() i = next; } } - { - boost::mutex::scoped_lock lock(m_closeSessionListMutex); - - CloseSessionList::iterator i = m_closeSessionList.begin(); - CloseSessionList::iterator end = m_closeSessionList.end(); - - while (i != end) - { - CloseSessionList::iterator cur = i++; - - if (cur->first.elapsed().total_seconds() >= SERVER_CLOSE_SESSION_DELAY_SEC) - m_closeSessionList.erase(cur); - } - } } void @@ -860,7 +834,7 @@ ServerLobbyThread::SessionError(SessionWrapper session, int errorCode) if (session.sessionData.get()) { SendError(session.sessionData, errorCode); - CloseSessionDelayed(session); + CloseSession(session); } } diff --git a/src/net/serverlobbythread.h b/src/net/serverlobbythread.h index 6363ec45..a8ee04a8 100644 --- a/src/net/serverlobbythread.h +++ b/src/net/serverlobbythread.h @@ -81,7 +81,6 @@ protected: typedef std::deque > ConnectQueue; typedef std::deque SessionQueue; typedef std::list SessionList; - typedef std::list > > CloseSessionList; typedef std::map InitTimerSessionMap; typedef std::map > GameMap; typedef std::list RemoveGameList; @@ -120,7 +119,7 @@ protected: void CleanupConnectQueue(); void CleanupSessionMap(); - void CloseSessionDelayed(SessionWrapper session); + void CloseSession(SessionWrapper session); void SendError(boost::shared_ptr s, int errorCode); void SendJoinGameFailed(boost::shared_ptr s, int reason); void SendGameList(boost::shared_ptr s); @@ -152,9 +151,6 @@ private: InitTimerSessionMap m_initTimerSessionMap; - CloseSessionList m_closeSessionList; - mutable boost::mutex m_closeSessionListMutex; - RemoveGameList m_removeGameList; mutable boost::mutex m_removeGameListMutex;