phxpaxos icon indicating copy to clipboard operation
phxpaxos copied to clipboard

tcp连接接收数据问题

Open ivanzz1001 opened this issue 6 years ago • 0 comments

看到tcp接收数据的模块。首先新的TCP连接进来,TcpAccepter会接受该连接,然后调用TcpAcceptor :: AddEvent()函数将其加入到一个负载最低的EventLoop中,在EventLoop :: AddEvent()将该文件句柄加入到m_oFDQueue之后,是否需要调用EventLoop :: JumpoutEpollWait()函数以通知EventLoop尽快将队列中的fd加入到epoll中,否则需要等到下一次超时后才能处理。

因此将EventLoop::AddEvent()改为如下是否较为合适: void EventLoop :: AddEvent(int iFD, SocketAddress oAddr) { std::lock_guardstd::mutex oLockGuard(m_oMutex); m_oFDQueue.push(make_pair(iFD, oAddr));

//新添加行 JumpoutEpollWait(); }

ivanzz1001 avatar Jul 29 '19 11:07 ivanzz1001