All pastes #994451 Raw Edit

Something

public text v1 · immutable
#994451 ·published 2008-04-23 12:43 UTC
rendered paste body
void SocketManager::Debug_CheckSockets()
{
	m_Mutex.Lock();
	SocketBase* pSocket = NULL;
	for(SocketSet::iterator itSocket = m_sockets.begin(); itSocket != m_sockets.end(); ++itSocket)
	{
		pSocket = (*itSocket);
		if(!pSocket->IsConnected() || pSocket->IsMarkedAsDisconnected())
			continue;

		if(!event_pending(&pSocket->m_ev_read, EV_READ, NULL))
		{
			sLog.outError("DEBUG: forcibly add_event(EV_READ)");
			if(LISTEN_S == pSocket->GetType())
			{
			#ifdef WIN32
				timeval tv = {0, 50000};
			#else
				timeval tv = {5, 0};
			#endif
				if(event_add(&pSocket->m_ev_read, &tv) == -1)
					sLog.outError("<Listen socket %u> Couldn't reschedule reading forcibly. Error [%u].", 
					pSocket->GetSocket(), errno);
			}
			else if(CONN_S == pSocket->GetType())
			{
				if(event_add(&pSocket->m_ev_read, NULL) == -1)
					sLog.outError("<Socket %u> Couldn't reschedule reading by timeout. Error [%u].", 
					pSocket->GetSocket(), errno);
			}
		}
//		else
//			sLog.outError("DEBUG: \"no events were registered\" but EV_READ is pending");
	}
	m_Mutex.Unlock();
}