void SyncHandler::ProcessActiveSessionList() { SESSION_LIST_ITER it; Session *pSession; for (it = m_pActiveSessionList->begin(); it != m_pActiveSessionList->end(); ++it) { pSession = *it; if ( pSession->ShouldBeRemoved() ){ continue; } if ( pSession->HasDisconnectOrdered() ) { if ( pSession->GetSendBuffer()->GetLength() == 0 ) { pSession->Remove(); } } else { if ( pSession->IsAcceptSocket() && pSession->IsOnIdle() ) { //pSession->OnLogString( "Idle Session." ); pSession->Remove(); continue; } if ( !pSession->ProcessRecvdPacket(m_dwMaxPacketSize) ) { pSession->Remove(); } } } }
void SyncHandler::KickDeadSession() { SESSION_LIST_ITER it, it2; Session *pSession; m_pActiveSessionList->Lock(); for (it = m_pActiveSessionList->begin(); it != m_pActiveSessionList->end();) { pSession = *it; if ( pSession->ShouldBeRemoved() ) { it2 = it++; m_pActiveSessionList->remove( it2 ); m_pTemplateList->push_back( pSession ); } else { ++it; } } m_pActiveSessionList->Unlock(); while ( !m_pTemplateList->empty() ) { Session * pSession = m_pTemplateList->pop_front(); --m_numActiveSessions; NetworkObject * pNet = pSession->GetNetworkObject(); pSession->UnbindNetworkObject(); DelEpollEvent( pSession ); FreeSession( pSession ); pNet->OnDisconnect(); if ( pSession->IsAcceptSocket() ) { m_fnDestroyAcceptedObject(pNet); } else { m_fnDestroyConnectedObject(pNet); } } }