提交 91bd6fa9 编写于 作者: S Shengliang Guan

[TD-814] close fd on error occurs

上级 13babe1c
...@@ -85,6 +85,7 @@ bool httpReadDataImp(HttpContext *pContext) { ...@@ -85,6 +85,7 @@ bool httpReadDataImp(HttpContext *pContext) {
} else { } else {
httpError("context:%p, fd:%d, ip:%s, read from socket error:%d, close connect", httpError("context:%p, fd:%d, ip:%s, read from socket error:%d, close connect",
pContext, pContext->fd, pContext->ipstr, errno); pContext, pContext->fd, pContext->ipstr, errno);
httpReleaseContext(pContext);
return false; return false;
} }
} else { } else {
...@@ -153,6 +154,7 @@ static bool httpReadData(HttpContext *pContext) { ...@@ -153,6 +154,7 @@ static bool httpReadData(HttpContext *pContext) {
int ret = httpCheckReadCompleted(pContext); int ret = httpCheckReadCompleted(pContext);
if (ret == HTTP_CHECK_BODY_CONTINUE) { if (ret == HTTP_CHECK_BODY_CONTINUE) {
//httpDebug("context:%p, fd:%d, ip:%s, not finished yet, wait another event", pContext, pContext->fd, pContext->ipstr); //httpDebug("context:%p, fd:%d, ip:%s, not finished yet, wait another event", pContext, pContext->fd, pContext->ipstr);
httpReleaseContext(pContext);
return false; return false;
} else if (ret == HTTP_CHECK_BODY_SUCCESS){ } else if (ret == HTTP_CHECK_BODY_SUCCESS){
httpDebug("context:%p, fd:%d, ip:%s, thread:%s, read size:%d, dataLen:%d", httpDebug("context:%p, fd:%d, ip:%s, thread:%s, read size:%d, dataLen:%d",
...@@ -161,11 +163,13 @@ static bool httpReadData(HttpContext *pContext) { ...@@ -161,11 +163,13 @@ static bool httpReadData(HttpContext *pContext) {
return true; return true;
} else { } else {
httpNotifyContextClose(pContext); httpNotifyContextClose(pContext);
httpReleaseContext(pContext);
return false; return false;
} }
} else { } else {
httpError("context:%p, fd:%d, ip:%s, failed to read http body, close connect", pContext, pContext->fd, pContext->ipstr); httpError("context:%p, fd:%d, ip:%s, failed to read http body, close connect", pContext, pContext->fd, pContext->ipstr);
httpNotifyContextClose(pContext); httpNotifyContextClose(pContext);
httpReleaseContext(pContext);
return false; return false;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册