From c9407a77269037b1a72887d085e8305dfab45af1 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 23 Nov 2022 11:31:13 +0800 Subject: [PATCH 1/2] fix mem leak --- source/libs/transport/src/transCli.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 5b8f059e04..d64d83bf9b 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -445,9 +445,11 @@ void cliHandleExceptImpl(SCliConn* pConn, int32_t code) { if (pCtx == NULL || pCtx->pSem == NULL) { if (transMsg.info.ahandle == NULL) { - if (pMsg == NULL || REQUEST_NO_RESP(&pMsg->msg) || pMsg->type == Release) destroyCmsg(pMsg); - once = true; - continue; + if (pMsg == NULL || REQUEST_NO_RESP(&pMsg->msg) || pMsg->type == Release) { + destroyCmsg(pMsg); + once = true; + continue; + } } } @@ -1214,9 +1216,12 @@ static FORCE_INLINE void destroyUserdata(STransMsg* userdata) { static FORCE_INLINE void destroyCmsg(void* arg) { SCliMsg* pMsg = arg; + tDebug("climsg free %p", pMsg); if (pMsg == NULL) { + tDebug("climsg no %p", pMsg); return; } + transDestroyConnCtx(pMsg->ctx); destroyUserdata(&pMsg->msg); taosMemoryFree(pMsg); @@ -1605,8 +1610,8 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran cliMsg->refId = (int64_t)shandle; STraceId* trace = &pReq->info.traceId; - tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid, - EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); + tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p, climsg: %p", transLabel(pTransInst), pThrd->pid, + EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle, cliMsg); if (0 != transAsyncSend(pThrd->asyncPool, &(cliMsg->q))) { destroyCmsg(cliMsg); transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); @@ -1651,8 +1656,8 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs cliMsg->refId = (int64_t)shandle; STraceId* trace = &pReq->info.traceId; - tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid, - EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); + tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p, climsg malloc: %p", transLabel(pTransInst), + pThrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle, cliMsg); int ret = transAsyncSend(pThrd->asyncPool, &cliMsg->q); if (ret != 0) { From 3f0ea98cb28a5f603be55803f3f09f8fd7032ae5 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 23 Nov 2022 11:33:03 +0800 Subject: [PATCH 2/2] fix mem leak --- source/libs/transport/src/transCli.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index d64d83bf9b..275048e94a 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -1216,9 +1216,7 @@ static FORCE_INLINE void destroyUserdata(STransMsg* userdata) { static FORCE_INLINE void destroyCmsg(void* arg) { SCliMsg* pMsg = arg; - tDebug("climsg free %p", pMsg); if (pMsg == NULL) { - tDebug("climsg no %p", pMsg); return; } @@ -1610,8 +1608,8 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran cliMsg->refId = (int64_t)shandle; STraceId* trace = &pReq->info.traceId; - tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p, climsg: %p", transLabel(pTransInst), pThrd->pid, - EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle, cliMsg); + tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid, + EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); if (0 != transAsyncSend(pThrd->asyncPool, &(cliMsg->q))) { destroyCmsg(cliMsg); transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); @@ -1656,8 +1654,8 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs cliMsg->refId = (int64_t)shandle; STraceId* trace = &pReq->info.traceId; - tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p, climsg malloc: %p", transLabel(pTransInst), - pThrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle, cliMsg); + tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid, + EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); int ret = transAsyncSend(pThrd->asyncPool, &cliMsg->q); if (ret != 0) {