Merge pull request #5765 from taosdata/hotfix/TD-3686

[TD-3686]mem still reachable issue
This commit is contained in:
haojun Liao 2021-04-10 15:37:01 +08:00 committed by GitHub
commit 4d31633b6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -73,6 +73,7 @@ static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row);
static void cqCreateStream(SCqContext *pContext, SCqObj *pObj); static void cqCreateStream(SCqContext *pContext, SCqObj *pObj);
int32_t cqObjRef = -1; int32_t cqObjRef = -1;
int32_t cqVnodeNum = 0;
void cqRmFromList(SCqObj *pObj) { void cqRmFromList(SCqObj *pObj) {
//LOCK in caller //LOCK in caller
@ -166,6 +167,8 @@ void *cqOpen(void *ahandle, const SCqCfg *pCfg) {
return NULL; return NULL;
} }
atomic_add_fetch_32(&cqVnodeNum, 1);
cqCreateRef(); cqCreateRef();
pContext->tmrCtrl = taosTmrInit(0, 0, 0, "CQ"); pContext->tmrCtrl = taosTmrInit(0, 0, 0, "CQ");
@ -240,6 +243,13 @@ void cqClose(void *handle) {
if (hasCq == 0) { if (hasCq == 0) {
freeSCqContext(pContext); freeSCqContext(pContext);
} }
int32_t remainn = atomic_sub_fetch_32(&cqVnodeNum, 1);
if (remainn <= 0) {
int32_t ref = cqObjRef;
cqObjRef = -1;
taosCloseRef(ref);
}
} }
void cqStart(void *handle) { void cqStart(void *handle) {