提交 39848d24 编写于 作者: D dapan1121

fix catalog quit issue

上级 dbe1d146
......@@ -1186,13 +1186,13 @@ void catalogDestroy(void) {
atomic_store_8((int8_t*)&gCtgMgmt.exit, true);
while (CTG_IS_LOCKED(&gCtgMgmt.lock)) {
taosUsleep(1);
}
if (tsem_post(&gCtgMgmt.queue.reqSem)) {
qError("tsem_post failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno)));
}
while (CTG_IS_LOCKED(&gCtgMgmt.lock)) {
taosUsleep(1);
}
CTG_LOCK(CTG_WRITE, &gCtgMgmt.lock);
......
......@@ -1614,23 +1614,32 @@ void ctgUpdateThreadUnexpectedStopped(void) {
}
void ctgCleanupCacheQueue(void) {
SCtgQNode *node = gCtgMgmt.queue.head->next;
SCtgQNode *node = NULL;
SCtgQNode *nodeNext = NULL;
while (node) {
if (node->op) {
taosMemoryFree(node->op->data);
if (node->op->syncOp) {
tsem_post(&node->op->rspSem);
} else {
taosMemoryFree(node->op);
while (true) {
node = gCtgMgmt.queue.head->next;
while (node) {
if (node->op) {
taosMemoryFree(node->op->data);
if (node->op->syncOp) {
tsem_post(&node->op->rspSem);
} else {
taosMemoryFree(node->op);
}
}
nodeNext = node->next;
taosMemoryFree(node);
node = nodeNext;
}
nodeNext = node->next;
taosMemoryFree(node);
node = nodeNext;
if (CTG_IS_LOCKED(&gCtgMgmt.lock)) {
taosUsleep(1);
} else {
break;
}
}
taosMemoryFreeClear(gCtgMgmt.queue.head);
......@@ -1652,6 +1661,7 @@ void* ctgUpdateThreadFunc(void* param) {
}
if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) {
CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock);
ctgCleanupCacheQueue();
break;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册