From 26c2f31341646f77d49dfba6691926ffd3671088 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Mon, 14 Feb 2022 10:58:33 +0800 Subject: [PATCH] feature/qnode --- source/libs/catalog/inc/catalogInt.h | 2 ++ source/libs/catalog/src/catalog.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 76a0bad195..5857437f9d 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -213,6 +213,8 @@ typedef struct SCtgAction { #define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000 +#define CTG_IS_LOCKED(_lock) atomic_load_32((_lock)) + #define CTG_LOCK(type, _lock) do { \ if (CTG_READ == (type)) { \ assert(atomic_load_32((_lock)) >= 0); \ diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 34c5261c17..f1c2395de4 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -2431,6 +2431,10 @@ void catalogDestroy(void) { tsem_post(&gCtgMgmt.sem); + while (CTG_IS_LOCKED(&gCtgMgmt.lock)) { + usleep(1); + } + CTG_LOCK(CTG_WRITE, &gCtgMgmt.lock); SCatalog *pCtg = NULL; -- GitLab