diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 77249e3f0bc378ebcdf1eca299305b9157c9432e..04e4978d4a0ebe4c96d480e233c773415c769f69 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -227,7 +227,7 @@ int hbHandleRsp(SClientHbBatchRsp* hbRsp); // cluster level SAppHbMgr* appHbMgrInit(SAppInstInfo* pAppInstInfo, char *key); -void appHbMgrCleanup(SAppHbMgr* pAppHbMgr); +void appHbMgrCleanup(void); // conn level int hbRegisterConn(SAppHbMgr* pAppHbMgr, int32_t connId, int64_t clusterId, int32_t hbType); diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index f6c473333cd463000238a26357c9c7bc728ba159..73ba59f7728d2eda897fa3c90af9dcd238312b74 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -430,22 +430,16 @@ SAppHbMgr* appHbMgrInit(SAppInstInfo* pAppInstInfo, char *key) { return pAppHbMgr; } -void appHbMgrCleanup(SAppHbMgr* pAppHbMgr) { - if (NULL == pAppHbMgr) { - return; - } - +void appHbMgrCleanup(void) { pthread_mutex_lock(&clientHbMgr.lock); int sz = taosArrayGetSize(clientHbMgr.appHbMgrs); for (int i = 0; i < sz; i++) { SAppHbMgr* pTarget = taosArrayGetP(clientHbMgr.appHbMgrs, i); - if (pAppHbMgr == pTarget) { - taosHashCleanup(pTarget->activeInfo); - pTarget->activeInfo = NULL; - taosHashCleanup(pTarget->connInfo); - pTarget->connInfo = NULL; - } + taosHashCleanup(pTarget->activeInfo); + pTarget->activeInfo = NULL; + taosHashCleanup(pTarget->connInfo); + pTarget->connInfo = NULL; } pthread_mutex_unlock(&clientHbMgr.lock); @@ -476,6 +470,7 @@ void hbMgrCleanUp() { if (old == 0) return; pthread_mutex_lock(&clientHbMgr.lock); + appHbMgrCleanup(); taosArrayDestroy(clientHbMgr.appHbMgrs); pthread_mutex_unlock(&clientHbMgr.lock); @@ -535,9 +530,6 @@ void hbDeregisterConn(SAppHbMgr* pAppHbMgr, SClientHbKey connKey) { return; } atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1); - if (atomic_load_32(&pAppHbMgr->connKeyCnt) <= 0) { - appHbMgrCleanup(pAppHbMgr); - } } int hbAddConnInfo(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, void* key, void* value, int32_t keyLen, int32_t valueLen) {