本文整理汇总了C++中TcpServer::IsRunning方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpServer::IsRunning方法的具体用法?C++ TcpServer::IsRunning怎么用?C++ TcpServer::IsRunning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpServer
的用法示例。
在下文中一共展示了TcpServer::IsRunning方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecvParse
void* TcpServer::RecvParse(void* pData)
{
TcpServer* pthis = NULL;
mio2_t m = NULL;
LPMESSAGE_DATA pMsg = NULL;
int iLen = 0;
if (pData) {
m = ((c2s_t)pData)->mio2;
pthis = (TcpServer*)(((c2s_t)pData)->pvoid);
}
if (!pthis || !m) {
gvLog(LOG_ERR_SYS, "(TcpServer::RecvParse) receive pool start fail by error param");
return NULL;
}
RecvParser* pRecvParser = new RecvParser();
if (!pRecvParser) return NULL;
LPMESSAGE_DATA pErrMsgData = NULL;
while (pthis->IsRunning()) {
pMsg = g_MsgListRecv->Get_Msg();
if (pMsg) {
gvLog(LOG_MSG, "(TcpServer::RecvParse) entering receive parser... iFd:%d", pMsg->iFd);
iLen = pRecvParser->ParserData(pMsg);
gvLog(LOG_MSG, "(TcpServer::RecvParse) MSG: iLen:%d iFd:%d", iLen, pMsg->iFd);
if (iLen > 0) {
//put into data parser
pthis->AddConnect();
pMsg = MatchPacketHandler::GetInstance()->Handling(pMsg, pErrMsgData);
if (NULL != pMsg){
g_MsgListData->Put_Msg(pMsg);
}
else if (NULL != pErrMsgData){
pErrMsgData->bSendAndClose = true;
g_MsgListSnd->Put_Msg(pErrMsgData);
}
else {
if (NULL != pMsg) {
gvLog(LOG_MSG, "(TcpServer::RecvParse) MSG: MatchPacketHandler() iFd:%d", pMsg->iFd);
}
}
} else {
if (iLen == 0) {
//maybe (errno == EWOULDBLOCK || errno == EINTR || errno == EAGAIN)
gvLog(LOG_MSG, "(TcpServer::RecvParse) (iLen == 0) iFd:%d", pMsg->iFd);
} else {
gvLog(LOG_MSG, "(TcpServer::RecvParse) mio2_close iFd:%d", pMsg->iFd);
mio2_close(m, pMsg->iFd);
}
gvLog(LOG_MSG, "(TcpServer::RecvParse) MSG: fail iFd:%d pMsg:%p", pMsg->iFd, pMsg);
PutIdleMsgBuff(pMsg);
}
gvLog(LOG_MSG, "(TcpServer::RecvParse) left receive parser... pMsg:%p", pMsg);
}
usleep(1);
}
}
示例2: MioRun
void* TcpServer::MioRun(void *pData)
{
TcpServer* pthis = NULL;
mio2_t m = NULL;
if (pData) {
m = ((c2s_t)pData)->mio2;
pthis = (TcpServer*)(((c2s_t)pData)->pvoid);
}
if (!pthis || !m) {
gvLog(LOG_ERR_SYS, "(TcpServer::MioRun) mio run start fail by error param");
return NULL;
}
while (pthis->IsRunning()) {
{
CAutoLock lock(&(pthis->m_tMutexMio));
mio2_run(m, 5);
}
usleep(1);
}
return NULL;
}
示例3: DataParse
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;
}
}
示例4: WaitHandle
void* TcpServer::WaitHandle(void* pData)
{
TcpServer* pthis = NULL;
mio2_t m = NULL;
if (pData) {
m = ((c2s_t)pData)->mio2;
pthis = (TcpServer*)(((c2s_t)pData)->pvoid);
}
if (!pthis || !m) {
gvLog(LOG_ERR_SYS, "(TcpServer::WaitHandle) wait pool start fail by error param");
return NULL;
}
LPMESSAGE_DATA pMsg = NULL;
size_t ileftUnsend;
int iSetp = 0;
bool bIsError = true;
unsigned int iTimeOut = 0;
while (pthis->IsRunning()) {
pMsg = g_MsgListWait->Get_Msg();
if (pMsg) {
bIsError = true;
if (ioctl(pMsg->iFd, SIOCOUTQ, (char*)&ileftUnsend) >= 0) {
if (0 == ileftUnsend) {
/// success
gvLog(LOG_MSG, "(TcpServer::WaitHandle) MSG: success iFd:%d pMsg:%p tokenid:%s msg:%s", pMsg->iFd, pMsg, pMsg->cBuffer, pMsg->pData->m_cRsp);
if (pMsg->bSendAndClose){
mio2_close(m, pMsg->iFd);
}
else {
PushManager::GetInstance()->SendSuccess(pMsg->iFd);
}
gvLog(LOG_MSG, "(TcpServer::WaitHandle) MSG: handle finish iFd:%d pMsg:%p tokenid:%s", pMsg->iFd, pMsg, pMsg->cBuffer);
pMsg->pData->m_cRsp[pMsg->pData->m_usRspTotal] = 0;
PutIdleMsgBuff(pMsg);
bIsError = false;
}
else {
iTimeOut = pMsg->lLastSendTime + WAITTIME_INVAL;
if (GetTickCount() < iTimeOut) {
/// wait
g_MsgListWait->Put_Msg(pMsg);
// gvLog(LOG_MSG, "(TcpServer::WaitHandle) MSG: GetTickCount:%d pMsg->lLastSendTime:%d", GetTickCount(), pMsg->lLastSendTime);
bIsError = false;
}
}
}
if (bIsError) {
/// fail
PushManager::GetInstance()->SendFail(pMsg);
mio2_close(m, pMsg->iFd);
gvLog(LOG_MSG, "(TcpServer::WaitHandle) MSG: fail iFd:%d pMsg:%p", pMsg->iFd, pMsg);
PutIdleMsgBuff(pMsg);
}
}
usleep(1);
}
return NULL;
}
示例5: RspParse
void* TcpServer::RspParse(void* pData)
{
TcpServer* pthis = NULL;
mio2_t m = NULL;
LPMESSAGE_DATA pMsg = NULL;
if (pData) {
m = ((c2s_t)pData)->mio2;
pthis = (TcpServer*)(((c2s_t)pData)->pvoid);
}
if (!pthis || !m) {
gvLog(LOG_ERR_SYS, "(TcpServer::RspParse) response pool start fail by error param");
return NULL;
}
RspParser* pRspParser = new RspParser();
if (!pRspParser) return NULL;
int iSendResult = 0;
while (pthis->IsRunning()) {
pMsg = g_MsgListSnd->Get_Msg();
if (pMsg) {
gvLog(LOG_MSG, "(TcpServer::RspParse) entering send parser... pMsg:%p pMsg->iFd:%d", pMsg, pMsg->iFd);
iSendResult = pRspParser->ParserData(pMsg);
gvLog(LOG_MSG, "(TcpServer::RspParse) iSendResult:%d pMsg->iFd:%d", iSendResult, pMsg->iFd);
if (0 == iSendResult) {
// time out
//send buffer reget
g_MsgListSnd->Put_Msg(pMsg);
}
else if (-1 == iSendResult){
// fail
/*
{
CAutoLock lock(&(pthis->m_tMutexMio));
mio_close_quick(m, pMsg->iFd);
}
*/
if (IsAvailableIndex(pMsg->iFd)) {
PushManager::GetInstance()->SendFail(pMsg);
mio2_close(m, pMsg->iFd);
}
else {
/// ERROR 不应该有这种情况出现
gvLog(LOG_ERR_USER, "(TcpServer::RspParse) ERR: pMsg->iFd:%d", pMsg->iFd);
}
gvLog(LOG_MSG, "(TcpServer::RspParse) MSG: fail iFd:%d pMsg:%p", pMsg->iFd, pMsg);
PutIdleMsgBuff(pMsg);
}
else if (-2 == iSendResult) {
// wait
}
else {
// success
gvLog(LOG_MSG, "(TcpServer::RspParse) iFd:%d pMsg->bSendAndClose:%d", pMsg->iFd, pMsg->bSendAndClose);
if (pMsg->bSendAndClose){
mio2_close(m, pMsg->iFd);
}
else {
PushManager::GetInstance()->SendSuccess(pMsg->iFd);
}
gvLog(LOG_MSG, "(TcpServer::RspParse) MSG: success iFd:%d pMsg:%p", pMsg->iFd, pMsg);
PutIdleMsgBuff(pMsg);
}
gvLog(LOG_MSG, "(TcpServer::RspParse) left send parser...");
}
usleep(1);
}
}