//================================================================================================= void SyncHandler::ProcessConnectSuccessList() { SESSION_LIST_ITER it; Session *pSession; SESSION_LIST activeList; m_pConnectSuccessList->Lock(); m_pTemplateList->splice( * m_pConnectSuccessList ); m_pConnectSuccessList->Unlock(); while( !m_pTemplateList->empty() ) { pSession = m_pTemplateList->pop_front(); if (this->AddEpollEvent( pSession )) { pSession->OnConnect(TRUE); activeList.push_back(pSession); } else { this->FreeSession(pSession); pSession->OnConnect(FALSE); } } if ( !activeList.empty() ) { m_numActiveSessions += (DWORD) activeList.size(); m_pActiveSessionList->Lock(); m_pActiveSessionList->splice( activeList ); m_pActiveSessionList->Unlock(); } }
bool kumo_db::startSession(SESSION_INFO info) { if (!checkSession(info.session)) { sessions.push_back(info); return true; } return 0; }
void SyncHandler::ProcessAcceptedSessionList() { SESSION_LIST_ITER it; Session *pSession; m_pAcceptedSessionList->Lock(); m_pTemplateList->splice( *m_pAcceptedSessionList ); m_pAcceptedSessionList->Unlock(); SESSION_LIST activeList; while( !m_pTemplateList->empty() ) { pSession = m_pTemplateList->pop_front(); if (m_numActiveSessions >= m_dwMaxAcceptSession) { printf("Connection full! no available accept socket! \n"); FreeSession(pSession); continue; } if (!AddEpollEvent(pSession)) { FreeSession(pSession); continue; } NetworkObject * pNet = m_fnCreateAcceptedObject(); assert(pNet); pSession->BindNetworkObject(pNet); pSession->OnAccept(); ++m_numActiveSessions; activeList.push_back(pSession); } if ( !activeList.empty() ) { m_pActiveSessionList->Lock(); m_pActiveSessionList->splice( activeList ); m_pActiveSessionList->Unlock(); } }