int CCSocketHandler::handle_output() { log_debug("*STEP: send data, len:[%d] netfd[%d]", _w.data_len(), netfd); if (_w.data_len() != 0) { int ret = ::send (netfd, _w.data(), _w.data_len(), 0); if(-1 == ret) { if(errno == EINTR || errno == EAGAIN || errno == EINPROGRESS) { log_boot("sending,INTR|EAGAIN|EINPROGRESS,errno:[%d]", errno); EnableOutput (); ApplyEvents (); _stage = CONN_DATA_SENDING; return _stage; } log_boot ("sending package to client failed, ret[%d]", ret); DisableInput (); DisableOutput (); ApplyEvents (); _stage = CONN_FATAL_ERROR; return _stage; } if(ret == (int)_w.data_len()) { log_debug("send complete, send len=[%d]",ret); DisableOutput(); ApplyEvents (); _w.skip(ret); _stage = CONN_SEND_DONE; return _stage; } else if (ret < (int)_w.data_len()) { log_debug("had sent part of data, send len=[%d]",ret); EnableOutput (); ApplyEvents (); _w.skip(ret); _stage = CONN_DATA_SENDING; return _stage; } } DisableOutput(); ApplyEvents (); _stage = CONN_FATAL_ERROR; log_debug("send process failure"); return _stage; }
void MyPipeFrame::OnProcessTerm(wxProcessEvent& WXUNUSED(event)) { DoGet(); wxDELETE(m_process); wxLogWarning(wxT("The other process has terminated, closing")); DisableInput(); DisableOutput(); }
void CCSocketHandler::Reset(){ log_debug("reset socket handler"); _w.skip( _w.data_len() ); _r.skip( _r.data_len() ); DisableInput(); DisableOutput(); ApplyEvents(); CPollerObject::DetachPoller(); if(netfd > 0) { ::close(netfd); } netfd = -1; _stage = CONN_IDLE; return; }
int CHelperUnit::send_to_cgi(void) { int ret = 0; int reConnectCount = 0; log_debug("_w data size:[%d]", _w.data_len()); logic: if (_w.data_len() != 0) { ret = ::send (netfd, _w.data(), _w.data_len(), 0); log_debug("sent packet size:[%d]", ret); if(-1 == ret) { if(errno == EINTR || errno == EAGAIN || errno == EINPROGRESS) { _send_error_times++; if(_send_error_times >= 50) { g_pErrorLog->logMsg("CHelperUnit::send_to_cgi, send error more"); reset_helper(); _stage = CONN_FATAL_ERROR; return -1; } EnableOutput (); ApplyEvents (); return CONN_DATA_SENDING; } log_error("*STEP: sending package to logic server failed, ret code[%d], errno:[%d], ip:[%s], port:[%d]", ret, errno, addr.c_str(), port); reset_helper(); _stage = CONN_FATAL_ERROR; return -1; } if(ret == (int)_w.data_len()) { _w.skip(ret); DisableOutput (); ApplyEvents(); _stage = CONN_SEND_DONE; //重置发送错误次数 _send_error_times = 0; log_debug ("*STEP: sent package to logic server, netfd[%d] packet size[%d]", netfd, ret); return ret; } else if (ret < (int)_w.data_len()) { EnableOutput (); ApplyEvents (); _w.skip(ret); _stage = CONN_DATA_SENDING; //重置发送错误次数 _send_error_times = 0; return ret; } DisableInput (); DisableOutput (); ApplyEvents(); _stage = CONN_FATAL_ERROR; log_debug ("*STEP: sending package to logic server in exception, netfd[%d]", netfd); return ret; } return ret; }