Commit 8d93f924 authored by 赵磊's avatar 赵磊
Browse files

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

parent e6b0e8d9
...@@ -858,6 +858,15 @@ unsigned long dictScan(dict *d, ...@@ -858,6 +858,15 @@ unsigned long dictScan(dict *d,
de = next; 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 { } else {
t0 = &d->ht[0]; t0 = &d->ht[0];
t1 = &d->ht[1]; t1 = &d->ht[1];
...@@ -892,22 +901,16 @@ unsigned long dictScan(dict *d, ...@@ -892,22 +901,16 @@ unsigned long dictScan(dict *d,
de = next; de = next;
} }
/* Increment bits not covered by the smaller mask */ /* Increment the reverse cursor not covered by the smaller mask.*/
v = (((v | m0) + 1) & ~m0) | (v & m0); v |= ~m1;
v = rev(v);
v++;
v = rev(v);
/* Continue while bits covered by mask difference is non-zero */ /* Continue while bits covered by mask difference is non-zero */
} while (v & (m0 ^ m1)); } 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; return v;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment