Commit 162acd8a authored by antirez's avatar antirez
Browse files

SCAN: when iterating ziplists or intsets always return cursor of 0.

The previous implementation assumed that the first call always happens
with cursor set to 0, this may not be the case, and we want to return 0
anyway otherwise the (broken) client code will loop forever.
parent 406be0ea
......@@ -452,6 +452,7 @@ void scanGenericCommand(redisClient *c, robj *o) {
while(intsetGet(o->ptr,pos++,&ll))
listAddNodeTail(keys,createStringObjectFromLongLong(ll));
cursor = 0;
} else if (o->type == REDIS_HASH || o->type == REDIS_ZSET) {
unsigned char *p = ziplistIndex(o->ptr,0);
unsigned char *vstr;
......@@ -465,6 +466,7 @@ void scanGenericCommand(redisClient *c, robj *o) {
createStringObjectFromLongLong(vll));
p = ziplistNext(o->ptr,p);
}
cursor = 0;
} else {
redisPanic("Not handled encoding in SCAN.");
}
......
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