提交 5cc26ce9 编写于 作者: H Haojun Liao

[td-225]fix bug found by regression test.

上级 339fe735
......@@ -40,8 +40,9 @@
#include "dnodeShell.h"
#include "dnodeTelemetry.h"
#include "module.h"
#include "qScript.h"
#include "mnode.h"
#include "qScript.h"
#include "tcache.h"
#if !defined(_MODULE) || !defined(_TD_LINUX)
int32_t moduleStart() { return 0; }
......@@ -207,6 +208,7 @@ void dnodeCleanUpSystem() {
dnodeCleanupComponents();
taos_cleanup();
taosCloseLog();
taosStopCacheRefreshWorker();
}
}
......
......@@ -178,6 +178,11 @@ void taosCacheCleanup(SCacheObj *pCacheObj);
*/
void taosCacheRefresh(SCacheObj *pCacheObj, __cache_free_fn_t fp);
/**
* stop background refresh worker thread
*/
void taosStopCacheRefreshWorker();
#ifdef __cplusplus
}
#endif
......
......@@ -70,6 +70,7 @@ static pthread_t cacheRefreshWorker = {0};
static pthread_once_t cacheThreadInit = PTHREAD_ONCE_INIT;
static pthread_mutex_t guard = PTHREAD_MUTEX_INITIALIZER;
static SArray* pCacheArrayList = NULL;
static bool stopRefreshWorker = false;
static void doInitRefreshThread(void) {
pCacheArrayList = taosArrayInit(4, POINTER_BYTES);
......@@ -685,6 +686,9 @@ void* taosCacheTimedRefresh(void *handle) {
while(1) {
taosMsleep(SLEEP_DURATION);
if (stopRefreshWorker) {
goto _end;
}
pthread_mutex_lock(&guard);
size_t size = taosArrayGetSize(pCacheArrayList);
......@@ -708,13 +712,10 @@ void* taosCacheTimedRefresh(void *handle) {
size = taosArrayGetSize(pCacheArrayList);
uDebug("%s is destroying, remove it from refresh list, remain cache obj:%"PRIzu, pCacheObj->name, size);
pCacheObj->deleting = 0; //reset the deleting flag to enable pCacheObj does self destroy process
pCacheObj->deleting = 0; //reset the deleting flag to enable pCacheObj to continue releasing resources.
// all contained caches has been marked to be removed, destroy the scanner it self.
if (size == 0) {
pthread_mutex_unlock(&guard);
goto _end;
}
pthread_mutex_unlock(&guard);
continue;
}
pthread_mutex_unlock(&guard);
......@@ -759,3 +760,7 @@ void taosCacheRefresh(SCacheObj *pCacheObj, __cache_free_fn_t fp) {
int64_t now = taosGetTimestampMs();
doCacheRefresh(pCacheObj, now, fp);
}
void taosStopCacheRefreshWorker() {
stopRefreshWorker = false;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册