From 6d7bff15cdd0ad95b79c85ac665bec7ceefc44d6 Mon Sep 17 00:00:00 2001 From: xywang Date: Mon, 6 Dec 2021 18:47:32 +0800 Subject: [PATCH] [TS-654]: fixed two crash bugs --- src/plugins/http/src/httpServer.c | 8 ++++++-- src/rpc/src/rpcTcp.c | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c index fff17a4194..1b0e60d2ec 100644 --- a/src/plugins/http/src/httpServer.c +++ b/src/plugins/http/src/httpServer.c @@ -404,9 +404,13 @@ static bool httpReadData(HttpContext *pContext) { return true; } } else if (nread < 0) { - if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) { + if (errno == EINTR) { + httpDebug("context:%p, fd:%d, read from socket error:%d, continue", pContext, pContext->fd, errno); + continue; + } else if (errno == EAGAIN || errno == EWOULDBLOCK) { httpDebug("context:%p, fd:%d, read from socket error:%d, wait another event", pContext, pContext->fd, errno); - continue; // later again + httpReleaseContext(pContext/*, false */); + return false; } else { httpError("context:%p, fd:%d, read from socket error:%d, close connect", pContext, pContext->fd, errno); taosCloseSocket(pContext->fd); diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 29d9790e70..54e80c4044 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -488,6 +488,12 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) { msgLen = (int32_t)htonl((uint32_t)rpcHead.msgLen); int32_t size = msgLen + tsRpcOverhead; + // TODO: reason not found yet, workaround to avoid first + if (size < 0) { + tError("%s %p invalid size for malloc, msgLen:%d, size:%d", pThreadObj->label, pFdObj->thandle, msgLen, size); + return -1; + } + buffer = malloc(size); if (NULL == buffer) { tError("%s %p TCP malloc(size:%d) fail", pThreadObj->label, pFdObj->thandle, msgLen); -- GitLab