Skip to content

Commit

Permalink
BLPOP inside MULTI/EXEC block no longer crashes, instead if the list …
Browse files Browse the repository at this point in the history
…is empty the behavior is like if the timeout is reached. This fixes Issue 285 (backported from master)
  • Loading branch information
antirez committed Sep 3, 2010
1 parent b059a56 commit efc8a6b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions redis.c
Expand Up @@ -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);
Expand Down

0 comments on commit efc8a6b

Please sign in to comment.