[td-225]fix bug found by regression test.
This commit is contained in:
parent
1df5946dc6
commit
97159f54da
|
@ -535,7 +535,7 @@ void taosCacheCleanup(SCacheObj *pCacheObj) {
|
||||||
pCacheObj->deleting = 1;
|
pCacheObj->deleting = 1;
|
||||||
|
|
||||||
// wait for the refresh thread quit before destroying the cache object.
|
// wait for the refresh thread quit before destroying the cache object.
|
||||||
while(atomic_load_ptr((void**)&pCacheArrayList) != 0) {
|
while(atomic_load_8(&pCacheObj->deleting) != 0) {
|
||||||
taosMsleep(50);
|
taosMsleep(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,18 +695,29 @@ void* taosCacheTimedRefresh(void *handle) {
|
||||||
for(int32_t i = 0; i < size; ++i) {
|
for(int32_t i = 0; i < size; ++i) {
|
||||||
pthread_mutex_lock(&guard);
|
pthread_mutex_lock(&guard);
|
||||||
SCacheObj* pCacheObj = taosArrayGetP(pCacheArrayList, i);
|
SCacheObj* pCacheObj = taosArrayGetP(pCacheArrayList, i);
|
||||||
pthread_mutex_unlock(&guard);
|
|
||||||
|
|
||||||
if (pCacheObj == NULL) {
|
if (pCacheObj == NULL) {
|
||||||
uDebug("object is destroyed. no refresh retry");
|
uError("object is destroyed. ignore and try next");
|
||||||
break;
|
pthread_mutex_unlock(&guard);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if current cache object will be deleted every 500ms.
|
// check if current cache object will be deleted every 500ms.
|
||||||
if (pCacheObj->deleting) {
|
if (pCacheObj->deleting) {
|
||||||
uDebug("%s is destroying, cache refresh thread quit", pCacheObj->name);
|
taosArrayRemove(pCacheArrayList, i);
|
||||||
|
size = taosArrayGetSize(pCacheArrayList);
|
||||||
|
|
||||||
|
uDebug("%s is destroying, remove it from refresh list, remain cache obj:%"PRId64, pCacheObj->name, size);
|
||||||
|
pCacheObj->deleting = 0; //reset the deleting flag to enable pCacheObj does self destroy process
|
||||||
|
|
||||||
|
// all contained caches has been marked to be removed, destroy the scanner it self.
|
||||||
|
if (size == 0) {
|
||||||
|
pthread_mutex_unlock(&guard);
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&guard);
|
||||||
|
|
||||||
if ((count % pCacheObj->checkTick) != 0) {
|
if ((count % pCacheObj->checkTick) != 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue