From a37f56f09bba340f80acb7dea292a4830f1e0378 Mon Sep 17 00:00:00 2001 From: lotodore Date: Wed, 22 Jul 2009 20:48:21 +0000 Subject: [PATCH] More paranoia stuff. --- src/net/common/serverlobbythread.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 3c100121..e27574eb 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -529,13 +529,13 @@ ServerLobbyThread::HandleRead(const boost::system::error_code &ec, SessionId ses { try { - // Find the session. - SessionWrapper session = m_sessionManager.GetSessionById(sessionId); - if (!session.sessionData) - session = m_gameSessionManager.GetSessionById(sessionId); - if (session.sessionData) + if (!ec) { - if (!ec) + // Find the session. + SessionWrapper session = m_sessionManager.GetSessionById(sessionId); + if (!session.sessionData) + session = m_gameSessionManager.GetSessionById(sessionId); + if (session.sessionData) { ReceiveBuffer &buf = session.sessionData->GetReceiveBuffer(); if (buf.recvBufUsed + bytesRead > RECV_BUF_SIZE) @@ -584,9 +584,16 @@ ServerLobbyThread::HandleRead(const boost::system::error_code &ec, SessionId ses boost::asio::placeholders::bytes_transferred)); } } - else if (ec != boost::asio::error::operation_aborted) + } + else if (ec != boost::asio::error::operation_aborted) + { + // On error: Close this session. + // Find the session. + SessionWrapper session = m_sessionManager.GetSessionById(sessionId); + if (!session.sessionData) + session = m_gameSessionManager.GetSessionById(sessionId); + if (session.sessionData) { - // On error: Close this session. boost::shared_ptr game = InternalGetGameFromId(session.sessionData->GetGameId()); if (game) game->ErrorRemoveSession(session);