void ReadIncome(aeEventLoop*el,int fd,void*privdata,int mask) { /*add----------------*/ LogDebug("read in come"); proxy_client*c=(proxy_client*)privdata; proxy_client*r=c->remote; //read things store in peer buffer char*buf; int len,nread=0; while(1){ buf=BufferListGetSpace(r->blist,&len); if(buf==NULL) break; nread=recv(fd,buf,len,0); if(nread==-1){ if(errno==EAGAIN){ nread=0; }else{ goto ERROR; } }else if(nread==0){ LogInfo("connection close"); goto ERROR; } if(nread){ BufferListPush(r->blist,nread); SetWriteEvent(r); //write to ... LogDebug("set write"); }else{ break; } } return; ERROR: c->OnError(c); /*add----------------*/ }
// client really want write, // which means we should keep the write event whether or not there's anything to write right now. void Client::WantWrite() { m_want_write = true; SetWriteEvent(); }