Merge pull request #15471 from taosdata/fix/TD-17800
fix:fix remove from cache issue
This commit is contained in:
commit
216d753eb4
|
@ -266,6 +266,7 @@ static void pushfrontNodeInEntryList(SCacheEntry *pEntry, SCacheNode *pNode) {
|
||||||
pNode->pNext = pEntry->next;
|
pNode->pNext = pEntry->next;
|
||||||
pEntry->next = pNode;
|
pEntry->next = pNode;
|
||||||
pEntry->num += 1;
|
pEntry->num += 1;
|
||||||
|
ASSERT((pEntry->next && pEntry->num > 0) || (NULL == pEntry->next && pEntry->num == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void removeNodeInEntryList(SCacheEntry *pe, SCacheNode *prev, SCacheNode *pNode) {
|
static void removeNodeInEntryList(SCacheEntry *pe, SCacheNode *prev, SCacheNode *pNode) {
|
||||||
|
@ -278,6 +279,7 @@ static void removeNodeInEntryList(SCacheEntry *pe, SCacheNode *prev, SCacheNode
|
||||||
|
|
||||||
pNode->pNext = NULL;
|
pNode->pNext = NULL;
|
||||||
pe->num -= 1;
|
pe->num -= 1;
|
||||||
|
ASSERT((pe->next && pe->num > 0) || (NULL == pe->next && pe->num == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE SCacheEntry *doFindEntry(SCacheObj *pCacheObj, const void *key, size_t keyLen) {
|
static FORCE_INLINE SCacheEntry *doFindEntry(SCacheObj *pCacheObj, const void *key, size_t keyLen) {
|
||||||
|
@ -657,15 +659,18 @@ void doTraverseElems(SCacheObj *pCacheObj, bool (*fp)(void *param, SCacheNode *p
|
||||||
|
|
||||||
taosWLockLatch(&pEntry->latch);
|
taosWLockLatch(&pEntry->latch);
|
||||||
|
|
||||||
|
SCacheNode **pPre = &pEntry->next;
|
||||||
SCacheNode *pNode = pEntry->next;
|
SCacheNode *pNode = pEntry->next;
|
||||||
while (pNode != NULL) {
|
while (pNode != NULL) {
|
||||||
SCacheNode *next = pNode->pNext;
|
SCacheNode *next = pNode->pNext;
|
||||||
|
|
||||||
if (fp(pSup, pNode)) {
|
if (fp(pSup, pNode)) {
|
||||||
|
pPre = &pNode->pNext;
|
||||||
pNode = pNode->pNext;
|
pNode = pNode->pNext;
|
||||||
} else {
|
} else {
|
||||||
pEntry->next = next;
|
*pPre = next;
|
||||||
pEntry->num -= 1;
|
pEntry->num -= 1;
|
||||||
|
ASSERT((pEntry->next && pEntry->num > 0) || (NULL == pEntry->next && pEntry->num == 0));
|
||||||
|
|
||||||
atomic_sub_fetch_ptr(&pCacheObj->numOfElems, 1);
|
atomic_sub_fetch_ptr(&pCacheObj->numOfElems, 1);
|
||||||
pNode = next;
|
pNode = next;
|
||||||
|
|
Loading…
Reference in New Issue