From bd2b9b2b3563b0c40836ad2514dfd1baceeede7a Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 4 Aug 2020 19:12:04 +0800 Subject: [PATCH] [td-225] add some logs. --- src/util/src/hash.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/util/src/hash.c b/src/util/src/hash.c index 8e4aa48127..19f22766d6 100644 --- a/src/util/src/hash.c +++ b/src/util/src/hash.c @@ -284,6 +284,7 @@ void *taosHashGetCB(SHashObj *pHashObj, const void *key, size_t keyLen, void (*f // no data, return directly if (atomic_load_32(&pe->num) == 0) { + __rd_unlock(&pHashObj->lock, pHashObj->type); return NULL; } @@ -295,6 +296,12 @@ void *taosHashGetCB(SHashObj *pHashObj, const void *key, size_t keyLen, void (*f taosRLockLatch(&pe->latch); } + if (pe->num > 0) { + assert(pe->next != NULL); + } else { + assert(pe->next == NULL); + } + SHashNode *pNode = doSearchInEntryList(pe, key, keyLen, hashVal); if (pNode != NULL) { if (fp != NULL) { @@ -342,6 +349,8 @@ 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; } @@ -374,6 +383,12 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe } } + if (pe->num == 0) { + assert(pe->next == NULL); + } else { + assert(pe->next != NULL); + } + if (pHashObj->type == HASH_ENTRY_LOCK) { taosWUnLockLatch(&pe->latch); } @@ -471,6 +486,8 @@ void taosHashCleanup(SHashObj *pHashObj) { } pNode = pEntry->next; + assert(pNode != NULL); + while (pNode) { pNext = pNode->next; FREE_HASH_NODE(pHashObj, pNode); @@ -655,6 +672,12 @@ void taosHashTableResize(SHashObj *pHashObj) { pe->num -= 1; pe->next = pNode->next; + if (pe->num == 0) { + assert(pe->next == NULL); + } else { + assert(pe->next != NULL); + } + SHashEntry *pNewEntry = pHashObj->hashList[j]; pushfrontNodeInEntryList(pNewEntry, pNode); } else { @@ -671,11 +694,25 @@ void taosHashTableResize(SHashObj *pHashObj) { // added into new slot SHashEntry *pNewEntry = pHashObj->hashList[j]; + + if (pNewEntry->num == 0) { + assert(pNewEntry->next == NULL); + } else { + assert(pNewEntry->next != NULL); + } + pushfrontNodeInEntryList(pNewEntry, pNext); } else { pNode = pNext; } } + + if (pe->num == 0) { + assert(pe->next == NULL); + } else { + assert(pe->next != NULL); + } + } } -- GitLab