summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2010-09-03 11:30:26 +0200
committerantirez <antirez@gmail.com>2010-09-03 11:30:26 +0200
commitefc8a6beee5f8ed034b2c31df3d72cd6eec6df9e (patch)
tree9ab407d103451359e7926f65e4b710677eabf8d2
parentb059a563d91b8e104dbfc2d449968936e2503e81 (diff)
downloadredis-efc8a6beee5f8ed034b2c31df3d72cd6eec6df9e.tar.gz
BLPOP inside MULTI/EXEC block no longer crashes, instead if the list is empty the behavior is like if the timeout is reached. This fixes Issue 285 (backported from master)
-rw-r--r--redis.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/redis.c b/redis.c
index 10fe937b4..59f84f17d 100644
--- a/redis.c
+++ b/redis.c
@@ -7752,6 +7752,14 @@ static void blockingPopGenericCommand(redisClient *c, int where) {
}
}
}
+
+ /* If we are inside a MULTI/EXEC and the list is empty the only thing
+ * we can do is treating it as a timeout (even with timeout 0). */
+ if (c->flags & REDIS_MULTI) {
+ addReply(c,shared.nullmultibulk);
+ return;
+ }
+
/* If the list is empty or the key does not exists we must block */
timeout = strtol(c->argv[c->argc-1]->ptr,NULL,10);
if (timeout > 0) timeout += time(NULL);