diff --git a/src/util/src/tref.c b/src/util/src/tref.c index dc9adb0858ced10513ae1b2d7a6b49be6b46a720..f5b3dce2f09e095fa5d53955b3f0e0da8bec4b1c 100644 --- a/src/util/src/tref.c +++ b/src/util/src/tref.c @@ -429,11 +429,6 @@ static int taosDecRefCount(int rsetId, int64_t rid, int remove) { if (pNode->next) { pNode->next->prev = pNode->prev; } - - (*pSet->fp)(pNode->p); - - uTrace("rsetId:%d p:%p rid:%" PRId64 "is removed, hash:%d count:%d, free mem: %p", rsetId, pNode->p, rid, hash, pSet->count, pNode); - free(pNode); released = 1; } else { uTrace("rsetId:%d p:%p rid:%" PRId64 "is released, hash:%d count:%d", rsetId, pNode->p, rid, hash, pSet->count); @@ -446,7 +441,14 @@ static int taosDecRefCount(int rsetId, int64_t rid, int remove) { taosUnlockList(pSet->lockedBy+hash); - if (released) taosDecRsetCount(pSet); + if (released) { + (*pSet->fp)(pNode->p); + + uTrace("rsetId:%d p:%p rid:%" PRId64 "is removed, hash:%d count:%d, free mem: %p", rsetId, pNode->p, rid, hash, pSet->count, pNode); + free(pNode); + + taosDecRsetCount(pSet); + } return code; }