From d324102f85ee33b8d184bd7c40f704ef0462689b Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 31 Jan 2021 00:05:33 +0000 Subject: [PATCH] TD-2885 --- src/cq/src/cqMain.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index a5de27d7fc..cc1628c968 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -125,8 +125,6 @@ void cqFree(void *handle) { pthread_mutex_unlock(&pContext->mutex); if (delete) { - pthread_mutex_unlock(&pContext->mutex); - pthread_mutex_destroy(&pContext->mutex); taosTmrCleanUp(pContext->tmrCtrl); @@ -186,6 +184,18 @@ void *cqOpen(void *ahandle, const SCqCfg *pCfg) { return pContext; } +static void freeSCqContext(void *handle) { + if (handle == NULL) { + return; + } + SCqContext *pContext = handle; + pthread_mutex_destroy(&pContext->mutex); + + taosTmrCleanUp(pContext->tmrCtrl); + pContext->tmrCtrl = NULL; + cDebug("vgId:%d, CQ is closed", pContext->vgId); + free(pContext); +} void cqClose(void *handle) { if (tsEnableStream == 0) { return; @@ -217,6 +227,7 @@ void cqClose(void *handle) { taosRemoveRef(cqObjRef, rid); } + freeSCqContext(pContext); } void cqStart(void *handle) { -- GitLab