taosIterateRef: shall NOT return removed node
This commit is contained in:
parent
3914317751
commit
7295cf43f9
|
@ -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,52 +290,56 @@ void *taosIterateRef(int rsetId, int64_t rid) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hash = 0;
|
do {
|
||||||
if (rid > 0) {
|
newP = NULL;
|
||||||
hash = rid % pSet->max;
|
int hash = 0;
|
||||||
taosLockList(pSet->lockedBy+hash);
|
if (rid > 0) {
|
||||||
|
hash = rid % pSet->max;
|
||||||
pNode = pSet->nodeList[hash];
|
|
||||||
while (pNode) {
|
|
||||||
if (pNode->rid == rid) break;
|
|
||||||
pNode = pNode->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pNode == NULL) {
|
|
||||||
uError("rsetId:%d rid:%" PRId64 " not there, quit", rsetId, rid);
|
|
||||||
terrno = TSDB_CODE_REF_NOT_EXIST;
|
|
||||||
taosUnlockList(pSet->lockedBy+hash);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// rid is there
|
|
||||||
pNode = pNode->next;
|
|
||||||
if (pNode == NULL) {
|
|
||||||
taosUnlockList(pSet->lockedBy+hash);
|
|
||||||
hash++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pNode == NULL) {
|
|
||||||
for (; hash < pSet->max; ++hash) {
|
|
||||||
taosLockList(pSet->lockedBy+hash);
|
taosLockList(pSet->lockedBy+hash);
|
||||||
|
|
||||||
pNode = pSet->nodeList[hash];
|
pNode = pSet->nodeList[hash];
|
||||||
if (pNode) break;
|
while (pNode) {
|
||||||
taosUnlockList(pSet->lockedBy+hash);
|
if (pNode->rid == rid) break;
|
||||||
|
pNode = pNode->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pNode == NULL) {
|
||||||
|
uError("rsetId:%d rid:%" PRId64 " not there, quit", rsetId, rid);
|
||||||
|
terrno = TSDB_CODE_REF_NOT_EXIST;
|
||||||
|
taosUnlockList(pSet->lockedBy+hash);
|
||||||
|
taosDecRsetCount(pSet);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// rid is there
|
||||||
|
pNode = pNode->next;
|
||||||
|
if (pNode == NULL) {
|
||||||
|
taosUnlockList(pSet->lockedBy+hash);
|
||||||
|
hash++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void *newP = NULL;
|
if (pNode == NULL) {
|
||||||
if (pNode) {
|
for (; hash < pSet->max; ++hash) {
|
||||||
pNode->count++; // acquire it
|
taosLockList(pSet->lockedBy+hash);
|
||||||
newP = pNode->p;
|
pNode = pSet->nodeList[hash];
|
||||||
taosUnlockList(pSet->lockedBy+hash);
|
if (pNode) break;
|
||||||
uTrace("rsetId:%d p:%p rid:%" PRId64 " is returned", rsetId, newP, rid);
|
taosUnlockList(pSet->lockedBy+hash);
|
||||||
} else {
|
}
|
||||||
uTrace("rsetId:%d the list is over", rsetId);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (rid > 0) taosReleaseRef(rsetId, rid); // release the current one
|
if (pNode) {
|
||||||
|
pNode->count++; // acquire it
|
||||||
|
newP = pNode->p;
|
||||||
|
taosUnlockList(pSet->lockedBy+hash);
|
||||||
|
uTrace("rsetId:%d p:%p rid:%" PRId64 " is returned", rsetId, newP, rid);
|
||||||
|
} else {
|
||||||
|
uTrace("rsetId:%d the list is over", rsetId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rid > 0) taosReleaseRef(rsetId, rid); // release the current one
|
||||||
|
if (pNode) rid = pNode->rid;
|
||||||
|
} while (newP && pNode->removed);
|
||||||
|
|
||||||
taosDecRsetCount(pSet);
|
taosDecRsetCount(pSet);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue