未验证 提交 969d6193 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #7889 from taosdata/merge/m1

merge from 2.0 into master
...@@ -36,7 +36,7 @@ typedef struct SHashNode { ...@@ -36,7 +36,7 @@ typedef struct SHashNode {
uint32_t dataLen; // length of data uint32_t dataLen; // length of data
uint32_t keyLen; // length of the key uint32_t keyLen; // length of the key
int8_t removed; // flag to indicate removed int8_t removed; // flag to indicate removed
int8_t count; // reference count int32_t count; // reference count
char data[]; char data[];
} SHashNode; } SHashNode;
......
...@@ -119,7 +119,7 @@ static SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *p ...@@ -119,7 +119,7 @@ static SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *p
static FORCE_INLINE SHashNode *doUpdateHashNode(SHashObj *pHashObj, SHashEntry* pe, SHashNode* prev, SHashNode *pNode, SHashNode *pNewNode) { static FORCE_INLINE SHashNode *doUpdateHashNode(SHashObj *pHashObj, SHashEntry* pe, SHashNode* prev, SHashNode *pNode, SHashNode *pNewNode) {
assert(pNode->keyLen == pNewNode->keyLen); assert(pNode->keyLen == pNewNode->keyLen);
pNode->count--; atomic_sub_fetch_32(&pNode->count, 1);
if (prev != NULL) { if (prev != NULL) {
prev->next = pNewNode; prev->next = pNewNode;
} else { } else {
...@@ -459,7 +459,7 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe ...@@ -459,7 +459,7 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe
if (pNode) { if (pNode) {
code = 0; // it is found code = 0; // it is found
pNode->count--; atomic_sub_fetch_32(&pNode->count, 1);
pNode->removed = 1; pNode->removed = 1;
if (pNode->count <= 0) { if (pNode->count <= 0) {
if (prevNode) { if (prevNode) {
...@@ -809,7 +809,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) { ...@@ -809,7 +809,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) {
pNode = pNode->next; pNode = pNode->next;
} }
pOld->count--; atomic_sub_fetch_32(&pOld->count, 1);
if (pOld->count <=0) { if (pOld->count <=0) {
if (prevNode) { if (prevNode) {
prevNode->next = pOld->next; prevNode->next = pOld->next;
...@@ -875,7 +875,7 @@ void *taosHashIterate(SHashObj *pHashObj, void *p) { ...@@ -875,7 +875,7 @@ void *taosHashIterate(SHashObj *pHashObj, void *p) {
if (pNode) { if (pNode) {
SHashEntry *pe = pHashObj->hashList[slot]; SHashEntry *pe = pHashObj->hashList[slot];
pNode->count++; atomic_add_fetch_32(&pNode->count, 1);
data = GET_HASH_NODE_DATA(pNode); data = GET_HASH_NODE_DATA(pNode);
if (pHashObj->type == HASH_ENTRY_LOCK) { if (pHashObj->type == HASH_ENTRY_LOCK) {
taosWUnLockLatch(&pe->latch); taosWUnLockLatch(&pe->latch);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册