Tencent / phxpaxos

The Paxos library implemented in C++ that has been used in the WeChat production environment.
Other
3.36k stars 863 forks source link

tcp连接接收数据问题 #168

Open ivanzz1001 opened 5 years ago

ivanzz1001 commented 5 years ago

看到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_guard oLockGuard(m_oMutex); m_oFDQueue.push(make_pair(iFD, oAddr));

//新添加行 JumpoutEpollWait(); }