From 76cd3122d1e848ce12cc78ac3a8e6f945e666b00 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Tue, 15 Nov 2022 14:28:20 +0800 Subject: [PATCH] fix: memory leak --- source/common/src/tmsg.c | 4 ++++ source/dnode/mnode/impl/src/mndSubscribe.c | 4 ++++ source/dnode/vnode/src/tq/tq.c | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index fd445ff2ae..4485e8df0c 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -6027,9 +6027,13 @@ int32_t tDecodeSMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) { void tDeleteSMqDataRsp(SMqDataRsp *pRsp) { taosArrayDestroy(pRsp->blockDataLen); + pRsp->blockDataLen = NULL; taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree); + pRsp->blockData = NULL; taosArrayDestroyP(pRsp->blockSchema, (FDelete)tDeleteSSchemaWrapper); + pRsp->blockSchema = NULL; taosArrayDestroyP(pRsp->blockTbName, (FDelete)taosMemoryFree); + pRsp->blockTbName = NULL; } int32_t tEncodeSTaosxRsp(SEncoder *pEncoder, const STaosxRsp *pRsp) { diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index 14adeb0080..fd79846104 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -471,8 +471,12 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu pConsumerNew->updateType = CONSUMER_UPDATE__TOUCH; mndReleaseConsumer(pMnode, pConsumerOld); if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) { + tDeleteSMqConsumerObj(pConsumerNew); + taosMemoryFree(pConsumerNew); goto REB_FAIL; } + tDeleteSMqConsumerObj(pConsumerNew); + taosMemoryFree(pConsumerNew); } // 3.2 set new consumer consumerNum = taosArrayGetSize(pOutput->newConsumers); diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index eafbd8464d..1cc771dbb4 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -68,6 +68,7 @@ static void destroySTqHandle(void* data) { static void tqPushEntryFree(void* data) { STqPushEntry* p = *(void**)data; + tDeleteSMqDataRsp(&p->dataRsp); taosMemoryFree(p); } @@ -576,8 +577,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { return 0; } } - taosWUnLockLatch(&pTq->pushLock); #endif + taosWUnLockLatch(&pTq->pushLock); if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { code = -1; -- GitLab