From 92b7a21490c6be8f4cfc98d5b45bf58897d4e2e1 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Tue, 24 Aug 2021 00:21:14 +0800 Subject: [PATCH] [TD-6169]: windows dll client can not quit. --- src/client/src/tscSystem.c | 2 ++ src/util/src/tcache.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index c04765b065..ad29b58660 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -199,7 +199,9 @@ void taos_init_imp(void) { // In the APIs of other program language, taos_cleanup is not available yet. // So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning. +#if !defined(TD_WINDOWS) atexit(taos_cleanup); +#endif tscDebug("client is initialized successfully"); } diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index be5584d182..dc1f961725 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -538,8 +538,8 @@ void taosCacheCleanup(SCacheObj *pCacheObj) { // wait for the refresh thread quit before destroying the cache object. // But in the dll, the child thread will be killed before atexit takes effect.So here we only wait for one second. - // while(atomic_load_8(&pCacheObj->deleting)) { - for (int i = 0; i < 60&&atomic_load_8(&pCacheObj->deleting) != 0; i++) { + while(atomic_load_8(&pCacheObj->deleting)) { + // for (int i = 0; i < 60&&atomic_load_8(&pCacheObj->deleting) != 0; i++) { taosMsleep(50); } @@ -721,6 +721,8 @@ void* taosCacheTimedRefresh(void *handle) { continue; } + pthread_mutex_unlock(&guard); + if ((count % pCacheObj->checkTick) != 0) { continue; } @@ -740,8 +742,6 @@ void* taosCacheTimedRefresh(void *handle) { } taosTrashcanEmpty(pCacheObj, false); - - pthread_mutex_unlock(&guard); } } -- GitLab