diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 8371b2596..ffaa25e33 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -153,20 +153,11 @@ void WorldSession::logUnexpectedOpcode(WorldPacket* packet, const char *reason) /// Update the WorldSession (triggered by World update) bool WorldSession::Update(uint32 /*diff*/) { - if (m_Socket && m_Socket->IsClosed ()) - { - m_Socket->RemoveReference (); - m_Socket = NULL; - } - - WorldPacket *packet; - ///- Retrieve packets from the receive queue and call the appropriate handlers - /// \todo Is there a way to consolidate the OpcondeHandlerTable and the g_worldOpcodeNames to only maintain 1 list? - /// answer : there is a way, but this is better, because it would use redundant RAM - while (!_recvQueue.empty()) + /// not proccess packets if socket already closed + while (!_recvQueue.empty() && m_Socket && !m_Socket->IsClosed ()) { - packet = _recvQueue.next(); + WorldPacket *packet = _recvQueue.next(); /*#if 1 sLog.outError( "MOEP: %s (0x%.4X)", @@ -226,6 +217,13 @@ bool WorldSession::Update(uint32 /*diff*/) delete packet; } + ///- Cleanup socket pointer if need + if (m_Socket && m_Socket->IsClosed ()) + { + m_Socket->RemoveReference (); + m_Socket = NULL; + } + ///- If necessary, log the player out time_t currTime = time(NULL); if (!m_Socket || (ShouldLogOut(currTime) && !m_playerLoading)) diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index e7e0bbc55..d80cc2362 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -112,10 +112,9 @@ void WorldSocket::CloseSocket (void) ACE_GUARD (LockType, Guard, m_OutBufferLock); if (closing_) - return; + return; closing_ = true; - peer ().close_writer (); } @@ -261,7 +260,7 @@ int WorldSocket::handle_input (ACE_HANDLE) if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) { - return Update (); // interesting line ,isn't it ? + return Update (); // interesting line ,isn't it ? } DEBUG_LOG ("WorldSocket::handle_input: Peer error closing connection errno = %s", ACE_OS::strerror (errno)); @@ -279,7 +278,7 @@ int WorldSocket::handle_input (ACE_HANDLE) case 1: return 1; default: - return Update (); // another interesting line ;) + return Update (); // another interesting line ;) } ACE_NOTREACHED(return -1); @@ -473,7 +472,7 @@ int WorldSocket::handle_input_missing_data (void) return -1; } - // We just received nice new header + // We just received nice new header if (handle_input_header () == -1) { ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN)); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4a197620a..b8116e7ab 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6897" + #define REVISION_NR "6898" #endif // __REVISION_NR_H__