适配网络库

This commit is contained in:
xiongziliang 2018-03-14 14:51:54 +08:00
parent d310978c21
commit 326d3a57c6

View File

@ -396,8 +396,6 @@ inline HttpSession::HttpCode HttpSession::Handle_Req_GET() {
}); });
GET_CONFIG_AND_REGISTER(uint32_t,sendBufSize,Config::Http::kSendBufSize); GET_CONFIG_AND_REGISTER(uint32_t,sendBufSize,Config::Http::kSendBufSize);
//缓存大小为两个包,太大可能导致发送时间太长从而超时
_sock->setSendPktSize(2);
weak_ptr<HttpSession> weakSelf = dynamic_pointer_cast<HttpSession>(shared_from_this()); weak_ptr<HttpSession> weakSelf = dynamic_pointer_cast<HttpSession>(shared_from_this());
auto onFlush = [pFilePtr,bClose,weakSelf,piLeft]() { auto onFlush = [pFilePtr,bClose,weakSelf,piLeft]() {
TimeTicker(); TimeTicker();
@ -424,7 +422,6 @@ inline HttpSession::HttpCode HttpSession::Handle_Req_GET() {
//InfoL << "send complete!" << iRead << " " << iReq << " " << *piLeft; //InfoL << "send complete!" << iRead << " " << iReq << " " << *piLeft;
if(iRead>0) { if(iRead>0) {
sendBuf->setSize(iRead); sendBuf->setSize(iRead);
strongSelf->_sock->setSendPktSize(3);//强制写入socket缓存
strongSelf->send(sendBuf); strongSelf->send(sendBuf);
} }
if(bClose) { if(bClose) {
@ -436,20 +433,20 @@ inline HttpSession::HttpCode HttpSession::Handle_Req_GET() {
sendBuf->setSize(iRead); sendBuf->setSize(iRead);
int iSent = strongSelf->send(sendBuf); int iSent = strongSelf->send(sendBuf);
if(iSent == -1) { if(iSent == -1) {
//send error
//InfoL << "send error"; //InfoL << "send error";
return false; return false;
} }
if(iSent < iRead) { if(iSent < iRead) {
//send wait
//InfoL << "send wait";
//数据回滚 //数据回滚
fseek(pFilePtr.get(), -iRead, SEEK_CUR); fseek(pFilePtr.get(), -iRead, SEEK_CUR);
*piLeft += iRead; *piLeft += iRead;
return true; return true;
} }
if(strongSelf->isSocketBusy()){
//套接字忙,那么停止继续写
return true;
}
//send success //send success
//InfoL << "send success";
} }
return false; return false;
}; };