From b190b0c98faff697dabbbde5524a5223a16a8bdb Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 27 May 2011 15:01:20 +0200 Subject: [PATCH] modified the BRPOPLPUSH target field cleanup strategy to fix it the proper way. --- src/t_list.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/t_list.c b/src/t_list.c index e945ed8b..00ae1edc 100644 --- a/src/t_list.c +++ b/src/t_list.c @@ -865,6 +865,9 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) { receiver = ln->value; dstkey = receiver->bpop.target; + /* Protect receiver->bpop.target, that will be freed by + * the next unblockClientWaitingData() call. */ + if (dstkey) incrRefCount(dstkey); /* This should remove the first element of the "clients" list. */ unblockClientWaitingData(receiver); @@ -877,13 +880,12 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) { } else { /* BRPOPLPUSH, note that receiver->db is always equal to c->db. */ dstobj = lookupKeyWrite(receiver->db,dstkey); - if (dstobj && checkType(receiver,dstobj,REDIS_LIST)) { - decrRefCount(dstkey); - } else { + if (!(dstobj && checkType(receiver,dstobj,REDIS_LIST))) { rpoplpushHandlePush(c,receiver,dstkey,dstobj,ele); decrRefCount(dstkey); return 1; } + decrRefCount(dstkey); } }