]> git.saurik.com Git - redis.git/commitdiff
fixed a problem with BLPOP timeout of zero, now it blocks forever
authorantirez <antirez@gmail.com>
Wed, 30 Dec 2009 00:11:05 +0000 (19:11 -0500)
committerantirez <antirez@gmail.com>
Wed, 30 Dec 2009 00:11:05 +0000 (19:11 -0500)
redis.c

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