mirror of
https://github.com/fluencelabs/redis
synced 2025-03-18 00:20:50 +00:00
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
This commit is contained in:
parent
8079656a8e
commit
fb92ecece7
@ -823,6 +823,13 @@ 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 */
|
/* If the list is empty or the key does not exists we must block */
|
||||||
timeout = strtol(c->argv[c->argc-1]->ptr,NULL,10);
|
timeout = strtol(c->argv[c->argc-1]->ptr,NULL,10);
|
||||||
if (timeout > 0) timeout += time(NULL);
|
if (timeout > 0) timeout += time(NULL);
|
||||||
|
@ -172,6 +172,17 @@ start_server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test {BLPOP inside a transaction} {
|
||||||
|
r del xlist
|
||||||
|
r lpush xlist foo
|
||||||
|
r lpush xlist bar
|
||||||
|
r multi
|
||||||
|
r blpop xlist 0
|
||||||
|
r blpop xlist 0
|
||||||
|
r blpop xlist 0
|
||||||
|
r exec
|
||||||
|
} {{xlist bar} {xlist foo} {}}
|
||||||
|
|
||||||
test {LPUSHX, RPUSHX - generic} {
|
test {LPUSHX, RPUSHX - generic} {
|
||||||
r del xlist
|
r del xlist
|
||||||
assert_equal 0 [r lpushx xlist a]
|
assert_equal 0 [r lpushx xlist a]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user