fix possible mem leak while driver quit (#33093)

This commit is contained in:
Yihao Deng 2025-09-29 13:52:49 +08:00 committed by GitHub
parent 2181b6e79b
commit 0f2f307d87
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -2396,15 +2396,26 @@ int32_t initCb(void* thrd, SCliReq* pReq, STransMsg* pResp) {
}
return cliMayCvtFqdnToIp(pReq->ctx->epSet, pThrd->pCvtAddr);
}
static void freeUserCtx(SCliReq* pReq) {
if (!pReq || !pReq->ctx) {
return;
}
transCtxCleanup(&pReq->ctx->userCtx);
}
int32_t notifyExceptCb(void* thrd, SCliReq* pReq, STransMsg* pResp) {
SCliThrd* pThrd = thrd;
STrans* pInst = pThrd->pInst;
int32_t code = cliBuildExceptResp(pThrd, pReq, pResp);
if (code != 0) {
freeUserCtx(pReq);
destroyReq(pReq);
return code;
}
pInst->cfp(pInst->parent, pResp, NULL);
freeUserCtx(pReq);
destroyReq(pReq);
return code;
}
@ -4246,7 +4257,6 @@ int32_t transAllocHandle(int64_t* refId) {
if (exh == NULL) {
return terrno;
}
exh->refId = transAddExHandle(transGetRefMgt(), exh);
if (exh->refId < 0) {
taosMemoryFree(exh);

View file

@ -513,6 +513,8 @@ void transCtxMerge(STransCtx* dst, STransCtx* src) {
}
taosHashCleanup(src->args);
src->args = NULL;
src->brokenVal.val = NULL;
}
void* transCtxDumpVal(STransCtx* ctx, int32_t key) {
if (ctx->args == NULL) {