fix mem leak
This commit is contained in:
parent
e3a2fb763c
commit
25a4645f08
|
@ -630,10 +630,29 @@ void appHbMgrCleanup(void) {
|
||||||
int sz = taosArrayGetSize(clientHbMgr.appHbMgrs);
|
int sz = taosArrayGetSize(clientHbMgr.appHbMgrs);
|
||||||
for (int i = 0; i < sz; i++) {
|
for (int i = 0; i < sz; i++) {
|
||||||
SAppHbMgr *pTarget = taosArrayGetP(clientHbMgr.appHbMgrs, 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);
|
taosHashCleanup(pTarget->activeInfo);
|
||||||
pTarget->activeInfo = NULL;
|
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);
|
taosHashCleanup(pTarget->connInfo);
|
||||||
pTarget->connInfo = NULL;
|
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) {
|
void hbDeregisterConn(SAppHbMgr *pAppHbMgr, SClientHbKey connKey) {
|
||||||
int32_t code = 0;
|
SClientHbReq *pReq = taosHashGet(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
||||||
code = taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
if (pReq) {
|
||||||
code = taosHashRemove(pAppHbMgr->connInfo, &connKey, sizeof(SClientHbKey));
|
hbFreeReq(pReq);
|
||||||
if (code) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1);
|
atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2749,4 +2749,15 @@ void schedulerDestroy(void) {
|
||||||
taosCloseRef(schMgmt.jobRef);
|
taosCloseRef(schMgmt.jobRef);
|
||||||
schMgmt.jobRef = 0;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue