未验证 提交 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) { ...@@ -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) { ...@@ -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,11 +307,17 @@ void *taosIterateRef(int rsetId, int64_t rid) { ...@@ -304,11 +307,17 @@ 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;
} }
// rid is there // rid is there
pNode = pNode->next; pNode = pNode->next;
// check first place
while (pNode) {
if (!pNode->removed) break;
pNode = pNode->next;
}
if (pNode == NULL) { if (pNode == NULL) {
taosUnlockList(pSet->lockedBy+hash); taosUnlockList(pSet->lockedBy+hash);
hash++; hash++;
...@@ -319,12 +328,18 @@ void *taosIterateRef(int rsetId, int64_t rid) { ...@@ -319,12 +328,18 @@ void *taosIterateRef(int rsetId, int64_t rid) {
for (; hash < pSet->max; ++hash) { for (; hash < pSet->max; ++hash) {
taosLockList(pSet->lockedBy+hash); taosLockList(pSet->lockedBy+hash);
pNode = pSet->nodeList[hash]; pNode = pSet->nodeList[hash];
if (pNode) {
// check first place
while (pNode) {
if (!pNode->removed) break;
pNode = pNode->next;
}
if (pNode) break; if (pNode) break;
}
taosUnlockList(pSet->lockedBy+hash); taosUnlockList(pSet->lockedBy+hash);
} }
} }
void *newP = NULL;
if (pNode) { if (pNode) {
pNode->count++; // acquire it pNode->count++; // acquire it
newP = pNode->p; newP = pNode->p;
...@@ -335,6 +350,8 @@ void *taosIterateRef(int rsetId, int64_t rid) { ...@@ -335,6 +350,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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册