taosIterateRef: shall NOT return removed node

This commit is contained in:
freemine 2021-01-28 22:44:53 +08:00
parent 3914317751
commit 7295cf43f9
1 changed files with 80 additions and 75 deletions

View File

@ -280,6 +280,7 @@ void *taosIterateRef(int rsetId, int64_t rid) {
return NULL; return NULL;
} }
void *newP = NULL;
pSet = tsRefSetList + rsetId; pSet = tsRefSetList + rsetId;
taosIncRsetCount(pSet); taosIncRsetCount(pSet);
if (pSet->state != TSDB_REF_STATE_ACTIVE) { if (pSet->state != TSDB_REF_STATE_ACTIVE) {
@ -289,6 +290,8 @@ void *taosIterateRef(int rsetId, int64_t rid) {
return NULL; return NULL;
} }
do {
newP = NULL;
int hash = 0; int hash = 0;
if (rid > 0) { if (rid > 0) {
hash = rid % pSet->max; hash = rid % pSet->max;
@ -304,6 +307,7 @@ void *taosIterateRef(int rsetId, int64_t rid) {
uError("rsetId:%d rid:%" PRId64 " not there, quit", rsetId, rid); uError("rsetId:%d rid:%" PRId64 " not there, quit", rsetId, rid);
terrno = TSDB_CODE_REF_NOT_EXIST; terrno = TSDB_CODE_REF_NOT_EXIST;
taosUnlockList(pSet->lockedBy+hash); taosUnlockList(pSet->lockedBy+hash);
taosDecRsetCount(pSet);
return NULL; return NULL;
} }
@ -324,7 +328,6 @@ void *taosIterateRef(int rsetId, int64_t rid) {
} }
} }
void *newP = NULL;
if (pNode) { if (pNode) {
pNode->count++; // acquire it pNode->count++; // acquire it
newP = pNode->p; newP = pNode->p;
@ -335,6 +338,8 @@ void *taosIterateRef(int rsetId, int64_t rid) {
} }
if (rid > 0) taosReleaseRef(rsetId, rid); // release the current one if (rid > 0) taosReleaseRef(rsetId, rid); // release the current one
if (pNode) rid = pNode->rid;
} while (newP && pNode->removed);
taosDecRsetCount(pSet); taosDecRsetCount(pSet);