More paranoia stuff.

This commit is contained in:
lotodore
2009-07-22 20:48:21 +00:00
parent d4131051dc
commit a37f56f09b
+9 -2
View File
@@ -528,14 +528,14 @@ void
ServerLobbyThread::HandleRead(const boost::system::error_code &ec, SessionId sessionId, size_t bytesRead) ServerLobbyThread::HandleRead(const boost::system::error_code &ec, SessionId sessionId, size_t bytesRead)
{ {
try try
{
if (!ec)
{ {
// Find the session. // Find the session.
SessionWrapper session = m_sessionManager.GetSessionById(sessionId); SessionWrapper session = m_sessionManager.GetSessionById(sessionId);
if (!session.sessionData) if (!session.sessionData)
session = m_gameSessionManager.GetSessionById(sessionId); session = m_gameSessionManager.GetSessionById(sessionId);
if (session.sessionData) if (session.sessionData)
{
if (!ec)
{ {
ReceiveBuffer &buf = session.sessionData->GetReceiveBuffer(); ReceiveBuffer &buf = session.sessionData->GetReceiveBuffer();
if (buf.recvBufUsed + bytesRead > RECV_BUF_SIZE) 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)); 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. // 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)
{
boost::shared_ptr<ServerGame> game = InternalGetGameFromId(session.sessionData->GetGameId()); boost::shared_ptr<ServerGame> game = InternalGetGameFromId(session.sessionData->GetGameId());
if (game) if (game)
game->ErrorRemoveSession(session); game->ErrorRemoveSession(session);