diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index a6678b2ec0881e74f1fa4c18723285258b1bf6c8..6159da9cb161e6604cbdd4f504114bf4b831b1d3 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -630,10 +630,29 @@ void appHbMgrCleanup(void) { int sz = taosArrayGetSize(clientHbMgr.appHbMgrs); for (int i = 0; i < sz; i++) { SAppHbMgr *pTarget = taosArrayGetP(clientHbMgr.appHbMgrs, i); + + void *pIter = taosHashIterate(pTarget->activeInfo, NULL); + while (pIter != NULL) { + SClientHbReq *pOneReq = pIter; + hbFreeReq(pOneReq); + taosHashCleanup(pOneReq->info); + pIter = taosHashIterate(pTarget->activeInfo, pIter); + } taosHashCleanup(pTarget->activeInfo); pTarget->activeInfo = NULL; + + + pIter = taosHashIterate(pTarget->connInfo, NULL); + while (pIter != NULL) { + SHbConnInfo *info = pIter; + taosMemoryFree(info->param); + pIter = taosHashIterate(pTarget->connInfo, pIter); + } taosHashCleanup(pTarget->connInfo); pTarget->connInfo = NULL; + + taosMemoryFree(pTarget->key); + taosMemoryFree(pTarget); } } @@ -716,12 +735,23 @@ int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, in } void hbDeregisterConn(SAppHbMgr *pAppHbMgr, SClientHbKey connKey) { - int32_t code = 0; - code = taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey)); - code = taosHashRemove(pAppHbMgr->connInfo, &connKey, sizeof(SClientHbKey)); - if (code) { + SClientHbReq *pReq = taosHashGet(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey)); + if (pReq) { + hbFreeReq(pReq); + taosHashCleanup(pReq->info); + taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey)); + } + + SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &connKey, sizeof(SClientHbKey)); + if (info) { + taosMemoryFree(info->param); + taosHashRemove(pAppHbMgr->connInfo, &connKey, sizeof(SClientHbKey)); + } + + if (NULL == pReq || NULL == info) { return; } + atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1); } diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 6cc435fee4b2be4dad426cd6c052c24919c8943c..c0b3ae7055d6b0d72784c40f7345476dc5126de7 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -2749,4 +2749,15 @@ void schedulerDestroy(void) { taosCloseRef(schMgmt.jobRef); schMgmt.jobRef = 0; } + + if (schMgmt.hbConnections) { + void *pIter = taosHashIterate(schMgmt.hbConnections, NULL); + while (pIter != NULL) { + SSchHbTrans *hb = pIter; + schFreeRpcCtx(&hb->rpcCtx); + pIter = taosHashIterate(schMgmt.hbConnections, pIter); + } + taosHashCleanup(schMgmt.hbConnections); + schMgmt.hbConnections = NULL; + } }