void CZSummerImpl::RunOnce() { int retCount = epoll_wait(m_epoll, m_events, 1000, m_timer.GetNextExpireTime()); if (retCount == -1) { if (errno != EINTR) { LCD(" epoll_wait err! errno=" <<strerror(errno)); return; //! error } return; } //check timer { m_timer.CheckTimer(); if (retCount == 0) return;//timeout } for (int i=0; i<retCount; i++) { int eventflag = m_events[i].events; tagRegister * pReg = (tagRegister *)m_events[i].data.ptr; //tagHandle type if (pReg->_type == tagRegister::REG_ZSUMMER) { char buf[1000]; while (recv(pReg->_fd, buf, 1000, 0) > 0); MsgVct msgs; m_msglock.lock(); msgs.swap(m_msgs); m_msglock.unlock(); for (auto iter = msgs.begin(); iter != msgs.end(); ++iter) { _OnPostHandler * p = (_OnPostHandler*)(*iter); (*p)(); delete p; } } else if (pReg->_type == tagRegister::REG_TCP_ACCEPT) { CTcpAcceptImpl *pKey = (CTcpAcceptImpl *) pReg->_ptr; if (eventflag & EPOLLIN) { pKey->OnEPOLLMessage(true); } if (eventflag & EPOLLERR || eventflag & EPOLLHUP) { pKey->OnEPOLLMessage(false); } } else if (pReg->_type == tagRegister::REG_TCP_SOCKET) { CTcpSocketImpl *pKey = (CTcpSocketImpl *) pReg->_ptr; pKey->OnEPOLLMessage(pReg->_type, eventflag); } else if (pReg->_type == tagRegister::REG_UDP_SOCKET) { CUdpSocketImpl *pKey = (CUdpSocketImpl *) pReg->_ptr; pKey->OnEPOLLMessage(pReg->_type, eventflag); } else { LCE("check register event type failed !! type=" << pReg->_type); } } }