summaryrefslogtreecommitdiff
path: root/src/db.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-11-05 15:32:21 +0100
committerantirez <antirez@gmail.com>2013-11-05 15:32:25 +0100
commitb4048dfec07eba76304140241f6c923271f7b396 (patch)
treea83c19c0566608441512e714792057ce65f9362c /src/db.c
parent101d4bf86724faf9a5abb251f6cc212546cc6c65 (diff)
downloadredis-b4048dfec07eba76304140241f6c923271f7b396.tar.gz
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.
Diffstat (limited to 'src/db.c')
-rw-r--r--src/db.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/db.c b/src/db.c
index c7de00496..1ed0bb2af 100644
--- a/src/db.c
+++ b/src/db.c
@@ -462,6 +462,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;
@@ -475,6 +476,7 @@ void scanGenericCommand(redisClient *c, robj *o) {
createStringObjectFromLongLong(vll));
p = ziplistNext(o->ptr,p);
}
+ cursor = 0;
} else {
redisPanic("Not handled encoding in SCAN.");
}