From 39e55b20218ba7dcf6c9bd8a7eb04841eea1a4cf Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 4 Sep 2020 10:33:57 +0800 Subject: [PATCH] [td-1315] --- src/util/src/tcache.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index e5526647cb..281576b507 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -364,16 +364,22 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) { * that tries to do the same thing. */ if (inTrashCan) { - ref = T_REF_DEC(pNode); + ref = T_REF_VAL_GET(pNode); - if (ref == 0) { + if (ref == 1) { // it is the last ref, assert(pNode->pTNodeHeader->pData == pNode); __cache_wr_lock(pCacheObj); doRemoveElemInTrashcan(pCacheObj, pNode->pTNodeHeader); __cache_unlock(pCacheObj); + ref = T_REF_DEC(pNode); + assert(ref == 0); + doDestroyTrashcanElem(pCacheObj, pNode->pTNodeHeader); + } else { + ref = T_REF_DEC(pNode); + assert(ref > 0); } } else { // NOTE: remove it from hash in the first place, otherwise, the pNode may have been released by other thread -- GitLab