- 论坛徽章:
- 6
|
呵呵,说错了,是毫秒,跟了一下程序流程,没发现错误的地方,跟踪消息的数据内容和window下都相同,机器发送消息量很大,而且很平繁,回复 4# linux_c_py_php
void * ServerWorkProc(LPVOID lpParameter)
{
CConnection * pConnection = NULL;
CNetServer * pCPS = (CNetServer * )lpParameter;
int iEpollHandle = pCPS->GetServerEpollfd(0);
struct epoll_event event;
struct epoll_event evReg;
int numEvents ;
while (true)
{
if(pCPS->m_bWorkProcExiting)
return NULL;
numEvents = epoll_wait(iEpollHandle, &event, 1, MAX_EPOLL_WAIT_TIME);
if( numEvents <= 0)
{
continue;
}
pConnection = (CConnection*)event.data.ptr;
if(pConnection == NULL|| !pConnection->IsConnected())
continue;
if(event.events & EPOLLOUT)
{
if(SendToConnection( pConnection) == FALSE)
{
epoll_ctl(iEpollHandle, EPOLL_CTL_DEL, pConnection->Socket(), &evReg);
pConnection->DisConnected();
Log(stderr,"epoll_ctl***SendToConnection fail!\n");
continue;
}
}
else if (event.events & EPOLLIN)
{
if(RecvFromConnection(pConnection) == FALSE)
{
epoll_ctl(iEpollHandle, EPOLL_CTL_DEL, pConnection->Socket(), &evReg);
pConnection->DisConnected();
Log(stderr,"epoll_ctl***RecvFromConnection fail!\n");
continue;
}
}
evReg.events = EPOLLIN | EPOLLONESHOT;
evReg.data.ptr = (void*)pConnection;
if(epoll_ctl(iEpollHandle, EPOLL_CTL_MOD, pConnection->Socket(), &evReg) != 0)
{
pConnection->DisConnected();
Log(stderr,"ServerWorkProc epoll_ctl fail!\n");
}
}
return NULL;
}
|
|