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

Merge pull request #5076 from freemine/mac

taosIterateRef: shall NOT return removed node
......@@ -280,6 +280,7 @@ void *taosIterateRef(int rsetId, int64_t rid) {
return NULL;
}
void *newP = NULL;
pSet = tsRefSetList + rsetId;
taosIncRsetCount(pSet);
if (pSet->state != TSDB_REF_STATE_ACTIVE) {
......@@ -289,6 +290,8 @@ void *taosIterateRef(int rsetId, int64_t rid) {
return NULL;
}
do {
newP = NULL;
int hash = 0;
if (rid > 0) {
hash = rid % pSet->max;
......@@ -304,11 +307,17 @@ void *taosIterateRef(int rsetId, int64_t rid) {
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;
// check first place
while (pNode) {
if (!pNode->removed) break;
pNode = pNode->next;
}
if (pNode == NULL) {
taosUnlockList(pSet->lockedBy+hash);
hash++;
......@@ -319,12 +328,18 @@ void *taosIterateRef(int rsetId, int64_t rid) {
for (; hash < pSet->max; ++hash) {
taosLockList(pSet->lockedBy+hash);
pNode = pSet->nodeList[hash];
if (pNode) {
// check first place
while (pNode) {
if (!pNode->removed) break;
pNode = pNode->next;
}
if (pNode) break;
}
taosUnlockList(pSet->lockedBy+hash);
}
}
void *newP = NULL;
if (pNode) {
pNode->count++; // acquire it
newP = pNode->p;
......@@ -335,6 +350,8 @@ void *taosIterateRef(int rsetId, int64_t rid) {
}
if (rid > 0) taosReleaseRef(rsetId, rid); // release the current one
if (pNode) rid = pNode->rid;
} while (newP && pNode->removed);
taosDecRsetCount(pSet);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册