[td-1315]

This commit is contained in:
Haojun Liao 2020-09-04 10:33:57 +08:00
parent 79bfe7a6a7
commit 39e55b2021
1 changed files with 8 additions and 2 deletions

View File

@ -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