Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dictScan(): It can't scan all buckets when dict is shrinking. #4907

Merged
merged 1 commit into from
Jun 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,15 @@ unsigned long dictScan(dict *d,
de = next;
}

/* Set unmasked bits so incrementing the reversed cursor
* operates on the masked bits */
v |= ~m0;

/* Increment the reverse cursor */
v = rev(v);
v++;
v = rev(v);

} else {
t0 = &d->ht[0];
t1 = &d->ht[1];
Expand Down Expand Up @@ -892,22 +901,16 @@ unsigned long dictScan(dict *d,
de = next;
}

/* Increment bits not covered by the smaller mask */
v = (((v | m0) + 1) & ~m0) | (v & m0);
/* Increment the reverse cursor not covered by the smaller mask.*/
v |= ~m1;
v = rev(v);
v++;
v = rev(v);

/* Continue while bits covered by mask difference is non-zero */
} while (v & (m0 ^ m1));
}

/* Set unmasked bits so incrementing the reversed cursor
* operates on the masked bits of the smaller table */
v |= ~m0;

/* Increment the reverse cursor */
v = rev(v);
v++;
v = rev(v);

return v;
}

Expand Down