Ejemplo n.º 1
0
bool SessionManager::AcceptSessions()
{
	FastSpinlockGuard guard(mLock);

	while (mCurrentIssueCount - mCurrentReturnCount < MAX_CONNECTION)
	{
		//TODO mFreeSessionList에서 ClientSession* 꺼내서 PostAccept() 해주기.. (위의 ReturnClientSession와 뭔가 반대로 하면 될 듯?)
		ClientSession* newClient = mFreeSessionList.front();
		mFreeSessionList.pop_front(); // pop_back하면 1개일때 에러가...??
		// AddRef()도 당연히 해줘야 하고...
		newClient->AddRef();

		// 실패시 false
		//if (false == newClient->PostAccept())
		//	return false;
		if( false == newClient->PostAccept() ){
			if( GetLastError() == ERROR_IO_PENDING )
				++mCurrentIssueCount;
			else
				return false;
		}
		else
			++mCurrentIssueCount;
	}


	return true;
}
Ejemplo n.º 2
0
bool SessionManager::AcceptSessions()
{
	FastSpinlockGuard guard(mLock);

	while (mCurrentIssueCount - mCurrentReturnCount < MAX_CONNECTION)
	{
		//TODO mFreeSessionList에서 ClientSession* 꺼내서 PostAccept() 해주기.. (위의 ReturnClientSession와 뭔가 반대로 하면 될 듯?)
		// AddRef()도 당연히 해줘야 하고...

	
		// 실패시 false
		//if (false == newClient->PostAccept())
		//	return false;
		////////////////////////////////////////////////////////////
		ClientSession * newClient = mFreeSessionList.back();
		mFreeSessionList.pop_back();
		++mCurrentIssueCount;
		newClient->AddRef();

		if (newClient->PostAccept() == false)
		{
			return false;
		}
		
		////////////////////////////////////////////////////////////
	}


	return true;
}
Ejemplo n.º 3
0
ClientSession* SessionManager::CreateClientSession(SOCKET sock)
{
	ClientSession* client = new ClientSession(sock);
	client->AddRef();

	mLock.EnterLock();
	{
		mClientList.insert(ClientList::value_type(sock, client));
	}
	mLock.LeaveLock();

	return client;
}
Ejemplo n.º 4
0
ClientSession* SessionManager::IssueClientSession()
{
	FastSpinlockGuard guard(mLock);

	uint64_t threadId = (mCurrentIssueCount++ % MAX_RIO_THREAD) + 1;
	CRASH_ASSERT(threadId > 0);

	CRASH_ASSERT((mCurrentIssueCount - mCurrentReturnCount) <= (MAX_RIO_THREAD*MAX_CLIENT_PER_RIO_THREAD));

	ClientSession* newClient = mFreeSessionList[threadId].back();
	mFreeSessionList[threadId].pop_back();

	newClient->AddRef();

	mOccupiedSessionList.push_back(newClient);

	return newClient;
}
Ejemplo n.º 5
0
bool ClientSessionManager::AcceptClientSessions()
{
	FastSpinlockGuard guard(mLock);

	while (mCurrentIssueCount - mCurrentReturnCount < MAX_CONNECTION)
	{
		ClientSession* newClient = mFreeSessionList.back();
		mFreeSessionList.pop_back();

		++mCurrentIssueCount;

		newClient->AddRef(); ///< refcount +1 for issuing 
		
		if (false == newClient->PostAccept())
			return false;
	}


	return true;
}
Ejemplo n.º 6
0
bool SessionManager::AcceptSessions()
{
	FastSpinlockGuard guard(mLock);

	//MAX_CONNECTION 개수만큼 Session을 유지하도록 socket만들어서 AcceptEx걸어놈
	while (mCurrentIssueCount - mCurrentReturnCount < MAX_CONNECTION)
	{
		//TODO mFreeSessionList에서 ClientSession* 꺼내서 PostAccept() 해주기.. (위의 ReturnClientSession와 뭔가 반대로 하면 될 듯?)
		ClientSession* newClient = mFreeSessionList.back();
		mFreeSessionList.pop_back();

		++mCurrentIssueCount;

		// AddRef()도 당연히 해줘야 하고...
		newClient->AddRef();

		// 실패시 false
		if (false == newClient->PostAccept())
			return false;
	}


	return true;
}