From 91bd6fa944c04de11c6f54db7769ab4196a50797 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 3 Jul 2020 10:20:57 +0800 Subject: [PATCH] [TD-814] close fd on error occurs --- src/plugins/http/src/httpServer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c index 6c82386d81..a5009c2347 100644 --- a/src/plugins/http/src/httpServer.c +++ b/src/plugins/http/src/httpServer.c @@ -85,6 +85,7 @@ bool httpReadDataImp(HttpContext *pContext) { } else { httpError("context:%p, fd:%d, ip:%s, read from socket error:%d, close connect", pContext, pContext->fd, pContext->ipstr, errno); + httpReleaseContext(pContext); return false; } } else { @@ -153,6 +154,7 @@ static bool httpReadData(HttpContext *pContext) { int ret = httpCheckReadCompleted(pContext); if (ret == HTTP_CHECK_BODY_CONTINUE) { //httpDebug("context:%p, fd:%d, ip:%s, not finished yet, wait another event", pContext, pContext->fd, pContext->ipstr); + httpReleaseContext(pContext); return false; } else if (ret == HTTP_CHECK_BODY_SUCCESS){ httpDebug("context:%p, fd:%d, ip:%s, thread:%s, read size:%d, dataLen:%d", @@ -161,11 +163,13 @@ static bool httpReadData(HttpContext *pContext) { return true; } else { httpNotifyContextClose(pContext); + httpReleaseContext(pContext); return false; } } else { httpError("context:%p, fd:%d, ip:%s, failed to read http body, close connect", pContext, pContext->fd, pContext->ipstr); httpNotifyContextClose(pContext); + httpReleaseContext(pContext); return false; } } -- GitLab