From b3c76157a1ee5644bdd24898f6b5ffeea125b88e Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 2 Sep 2020 10:09:58 +0800 Subject: [PATCH] [td-225] --- src/util/src/hash.c | 1 - src/util/src/tcache.c | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/util/src/hash.c b/src/util/src/hash.c index 7d10545ce7..2912b0a891 100644 --- a/src/util/src/hash.c +++ b/src/util/src/hash.c @@ -327,7 +327,6 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe // no data, return directly if (pe->num == 0) { - assert(pe->next == NULL); __rd_unlock(&pHashObj->lock, pHashObj->type); return -1; } diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index dfa982b848..9df05a0ee8 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -381,10 +381,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) { if (ret == 0) { if (ref > 0) { assert(pNode->pTNodeHeader == NULL); - - __cache_wr_lock(pCacheObj); taosAddToTrash(pCacheObj, pNode); - __cache_unlock(pCacheObj); } else { // ref == 0 atomic_sub_fetch_64(&pCacheObj->totalSize, pNode->size); @@ -485,18 +482,21 @@ void taosAddToTrash(SCacheObj *pCacheObj, SCacheDataNode *pNode) { STrashElem *pElem = calloc(1, sizeof(STrashElem)); pElem->pData = pNode; + pElem->prev = NULL; + + pNode->pTNodeHeader = pElem; + pNode->inTrashCan = true; + + __cache_wr_lock(pCacheObj); pElem->next = pCacheObj->pTrash; if (pCacheObj->pTrash) { pCacheObj->pTrash->prev = pElem; } - pElem->prev = NULL; pCacheObj->pTrash = pElem; - - pNode->inTrashCan = true; - pNode->pTNodeHeader = pElem; pCacheObj->numOfElemsInTrash++; + __cache_unlock(pCacheObj); uDebug("%s key:%p, %p move to trash, numOfElem in trash:%d", pCacheObj->name, pNode->key, pNode->data, pCacheObj->numOfElemsInTrash); -- GitLab