Commit 58d976b8 authored by antirez's avatar antirez
Browse files

fixed a problem with BLPOP timeout of zero, now it blocks forever

parent f86a74e9
...@@ -901,7 +901,7 @@ static void closeTimedoutClients(void) { ...@@ -901,7 +901,7 @@ static void closeTimedoutClients(void) {
redisLog(REDIS_DEBUG,"Closing idle client"); redisLog(REDIS_DEBUG,"Closing idle client");
freeClient(c); freeClient(c);
} else if (c->flags & REDIS_BLOCKED) { } else if (c->flags & REDIS_BLOCKED) {
if (c->blockingto < now) { if (c->blockingto != 0 && c->blockingto < now) {
addReply(c,shared.nullbulk); addReply(c,shared.nullbulk);
unblockClient(c); unblockClient(c);
} }
...@@ -5503,6 +5503,7 @@ static void blockForKey(redisClient *c, robj *key, time_t timeout) { ...@@ -5503,6 +5503,7 @@ static void blockForKey(redisClient *c, robj *key, time_t timeout) {
if (de == NULL) { if (de == NULL) {
int retval; int retval;
/* We take a list of clients blocked for a given key */
l = listCreate(); l = listCreate();
retval = dictAdd(c->db->blockingkeys,key,l); retval = dictAdd(c->db->blockingkeys,key,l);
incrRefCount(key); incrRefCount(key);
...@@ -5510,6 +5511,7 @@ static void blockForKey(redisClient *c, robj *key, time_t timeout) { ...@@ -5510,6 +5511,7 @@ static void blockForKey(redisClient *c, robj *key, time_t timeout) {
} else { } else {
l = dictGetEntryVal(de); l = dictGetEntryVal(de);
} }
/* Add this client to the list, and mark it as blocked */
listAddNodeTail(l,c); listAddNodeTail(l,c);
c->flags |= REDIS_BLOCKED; c->flags |= REDIS_BLOCKED;
aeDeleteFileEvent(server.el,c->fd,AE_READABLE); aeDeleteFileEvent(server.el,c->fd,AE_READABLE);
......
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