[td-225]fix bug found by regression test.
This commit is contained in:
parent
339fe7358b
commit
5cc26ce991
|
@ -40,8 +40,9 @@
|
||||||
#include "dnodeShell.h"
|
#include "dnodeShell.h"
|
||||||
#include "dnodeTelemetry.h"
|
#include "dnodeTelemetry.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "qScript.h"
|
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
|
#include "qScript.h"
|
||||||
|
#include "tcache.h"
|
||||||
|
|
||||||
#if !defined(_MODULE) || !defined(_TD_LINUX)
|
#if !defined(_MODULE) || !defined(_TD_LINUX)
|
||||||
int32_t moduleStart() { return 0; }
|
int32_t moduleStart() { return 0; }
|
||||||
|
@ -207,6 +208,7 @@ void dnodeCleanUpSystem() {
|
||||||
dnodeCleanupComponents();
|
dnodeCleanupComponents();
|
||||||
taos_cleanup();
|
taos_cleanup();
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
|
taosStopCacheRefreshWorker();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,11 @@ void taosCacheCleanup(SCacheObj *pCacheObj);
|
||||||
*/
|
*/
|
||||||
void taosCacheRefresh(SCacheObj *pCacheObj, __cache_free_fn_t fp);
|
void taosCacheRefresh(SCacheObj *pCacheObj, __cache_free_fn_t fp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stop background refresh worker thread
|
||||||
|
*/
|
||||||
|
void taosStopCacheRefreshWorker();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -70,6 +70,7 @@ static pthread_t cacheRefreshWorker = {0};
|
||||||
static pthread_once_t cacheThreadInit = PTHREAD_ONCE_INIT;
|
static pthread_once_t cacheThreadInit = PTHREAD_ONCE_INIT;
|
||||||
static pthread_mutex_t guard = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t guard = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static SArray* pCacheArrayList = NULL;
|
static SArray* pCacheArrayList = NULL;
|
||||||
|
static bool stopRefreshWorker = false;
|
||||||
|
|
||||||
static void doInitRefreshThread(void) {
|
static void doInitRefreshThread(void) {
|
||||||
pCacheArrayList = taosArrayInit(4, POINTER_BYTES);
|
pCacheArrayList = taosArrayInit(4, POINTER_BYTES);
|
||||||
|
@ -685,6 +686,9 @@ void* taosCacheTimedRefresh(void *handle) {
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
taosMsleep(SLEEP_DURATION);
|
taosMsleep(SLEEP_DURATION);
|
||||||
|
if (stopRefreshWorker) {
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&guard);
|
pthread_mutex_lock(&guard);
|
||||||
size_t size = taosArrayGetSize(pCacheArrayList);
|
size_t size = taosArrayGetSize(pCacheArrayList);
|
||||||
|
@ -708,13 +712,10 @@ void* taosCacheTimedRefresh(void *handle) {
|
||||||
size = taosArrayGetSize(pCacheArrayList);
|
size = taosArrayGetSize(pCacheArrayList);
|
||||||
|
|
||||||
uDebug("%s is destroying, remove it from refresh list, remain cache obj:%"PRIzu, pCacheObj->name, size);
|
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);
|
pthread_mutex_unlock(&guard);
|
||||||
goto _end;
|
continue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&guard);
|
pthread_mutex_unlock(&guard);
|
||||||
|
@ -759,3 +760,7 @@ void taosCacheRefresh(SCacheObj *pCacheObj, __cache_free_fn_t fp) {
|
||||||
int64_t now = taosGetTimestampMs();
|
int64_t now = taosGetTimestampMs();
|
||||||
doCacheRefresh(pCacheObj, now, fp);
|
doCacheRefresh(pCacheObj, now, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void taosStopCacheRefreshWorker() {
|
||||||
|
stopRefreshWorker = false;
|
||||||
|
}
|
Loading…
Reference in New Issue