/* int TcpServer::_c2s_client_mio_callback(mio_t m, mio_action_t a, int fd, void *data, void *arg) */ int TcpServer::_c2s_client_mio2_callback(mio2_t m, mio2_action_t a, int fd, void *data, void *arg) { TcpServer* pthis = NULL; c2s_t c2s = NULL; if (arg) { c2s = (c2s_t)arg; pthis = (TcpServer*)(((c2s_t)arg)->pvoid); } switch(a) { /* case action_READ: */ case mio2_action_READ: //do NOT accept new connect while restart if (pthis->IsRestarting()) { return 0; } return pthis->RevData(fd, m); /* case action_WRITE: */ case mio2_action_WRITE: /* return 0; */ return 1; /* case action_CLOSE: */ case mio2_action_CLOSE: return 0; /* case action_ACCEPT: */ case mio2_action_ACCEPT: //c2s->highfd = GetHighfd(m); gvLog(LOG_MSG, "(TcpServer::_c2s_client_mio_callback) Accept connect IP=%s(%d)...", data, fd); //add by using epoll return 1; } return 0; }
void* TcpServer::DataParse(void* pData) { TcpServer* pthis = NULL; mio2_t m = NULL; LPMESSAGE_DATA pMsg = NULL; DataParser* pDataParser = NULL; if (pData) { m = ((c2s_t)pData)->mio2; pthis = (TcpServer*)(((c2s_t)pData)->pvoid); } if (!pthis || !m) { gvLog(LOG_ERR_SYS, "(TcpServer::DataParse) process pool start fail by error param"); return NULL; } pDataParser = new DataParser(); if (!pDataParser) goto ErrDataParse; while (pthis->IsRunning() && !pthis->IsRestarting()) { pMsg = g_MsgListData->Get_Msg(); if (pMsg) { gvLog(LOG_MSG, "(TcpServer::DataParse) entering data parser..."); pDataParser->ParserData(pMsg); gvLog(LOG_MSG, "(TcpServer::DataParse) left data parser..."); g_MsgListSnd->Put_Msg(pMsg); } usleep(1); } ErrDataParse: // if (pVerDBMapping) { // pVerDBMapping->UnInit(); // delete pVerDBMapping; // } if (pDataParser) { delete pDataParser; } }