[td-225]
This commit is contained in:
parent
88ba66dd8b
commit
b3c76157a1
|
@ -327,7 +327,6 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe
|
||||||
|
|
||||||
// no data, return directly
|
// no data, return directly
|
||||||
if (pe->num == 0) {
|
if (pe->num == 0) {
|
||||||
assert(pe->next == NULL);
|
|
||||||
__rd_unlock(&pHashObj->lock, pHashObj->type);
|
__rd_unlock(&pHashObj->lock, pHashObj->type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,10 +381,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
if (ref > 0) {
|
if (ref > 0) {
|
||||||
assert(pNode->pTNodeHeader == NULL);
|
assert(pNode->pTNodeHeader == NULL);
|
||||||
|
|
||||||
__cache_wr_lock(pCacheObj);
|
|
||||||
taosAddToTrash(pCacheObj, pNode);
|
taosAddToTrash(pCacheObj, pNode);
|
||||||
__cache_unlock(pCacheObj);
|
|
||||||
} else { // ref == 0
|
} else { // ref == 0
|
||||||
atomic_sub_fetch_64(&pCacheObj->totalSize, pNode->size);
|
atomic_sub_fetch_64(&pCacheObj->totalSize, pNode->size);
|
||||||
|
|
||||||
|
@ -485,18 +482,21 @@ void taosAddToTrash(SCacheObj *pCacheObj, SCacheDataNode *pNode) {
|
||||||
|
|
||||||
STrashElem *pElem = calloc(1, sizeof(STrashElem));
|
STrashElem *pElem = calloc(1, sizeof(STrashElem));
|
||||||
pElem->pData = pNode;
|
pElem->pData = pNode;
|
||||||
|
pElem->prev = NULL;
|
||||||
|
|
||||||
|
pNode->pTNodeHeader = pElem;
|
||||||
|
pNode->inTrashCan = true;
|
||||||
|
|
||||||
|
__cache_wr_lock(pCacheObj);
|
||||||
|
|
||||||
pElem->next = pCacheObj->pTrash;
|
pElem->next = pCacheObj->pTrash;
|
||||||
if (pCacheObj->pTrash) {
|
if (pCacheObj->pTrash) {
|
||||||
pCacheObj->pTrash->prev = pElem;
|
pCacheObj->pTrash->prev = pElem;
|
||||||
}
|
}
|
||||||
|
|
||||||
pElem->prev = NULL;
|
|
||||||
pCacheObj->pTrash = pElem;
|
pCacheObj->pTrash = pElem;
|
||||||
|
|
||||||
pNode->inTrashCan = true;
|
|
||||||
pNode->pTNodeHeader = pElem;
|
|
||||||
pCacheObj->numOfElemsInTrash++;
|
pCacheObj->numOfElemsInTrash++;
|
||||||
|
__cache_unlock(pCacheObj);
|
||||||
|
|
||||||
uDebug("%s key:%p, %p move to trash, numOfElem in trash:%d", pCacheObj->name, pNode->key, pNode->data,
|
uDebug("%s key:%p, %p move to trash, numOfElem in trash:%d", pCacheObj->name, pNode->key, pNode->data,
|
||||||
pCacheObj->numOfElemsInTrash);
|
pCacheObj->numOfElemsInTrash);
|
||||||
|
|
Loading…
Reference in New Issue