Example #1
0
//=================================================================================================
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();
	}
}
Example #2
0
SESSION_INFO kumo_db::getSession(long session_id)
{
	SESSION_LIST_ITERATOR iterator = sessions.begin();
	while(iterator != sessions.end())
	{
		if (iterator->session == session_id)
			return *iterator;
		iterator++;
	}
	return SESSION_INFO();
}
Example #3
0
bool kumo_db::checkSession(long session_id)
{
	SESSION_LIST_ITERATOR iterator = sessions.begin();
	while(iterator != sessions.end())
	{
		if (iterator->session == session_id)
			return true;
		iterator++;
	}
	return false;
}
Example #4
0
bool kumo_db::startSession(SESSION_INFO info)
{
	if (!checkSession(info.session))
	{
		sessions.push_back(info);
		return true;
	}
	return 0;
}
Example #5
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();
	}
}