mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
Now the PUSH side of RPOPLPUSH is able to unblock clients blocked on BLPOP
This commit is contained in:
parent
08ff05b012
commit
e20fb74f69
14
redis.c
14
redis.c
@ -3862,20 +3862,24 @@ static void rpoplpushcommand(redisClient *c) {
|
|||||||
robj *ele = listNodeValue(ln);
|
robj *ele = listNodeValue(ln);
|
||||||
list *dstlist;
|
list *dstlist;
|
||||||
|
|
||||||
if (dobj == NULL) {
|
if (dobj && dobj->type != REDIS_LIST) {
|
||||||
|
addReply(c,shared.wrongtypeerr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add the element to the target list (unless it's directly
|
||||||
|
* passed to some BLPOP-ing client */
|
||||||
|
if (!handleClientsWaitingListPush(c,c->argv[2],ele)) {
|
||||||
|
if (dobj == NULL) {
|
||||||
/* Create the list if the key does not exist */
|
/* Create the list if the key does not exist */
|
||||||
dobj = createListObject();
|
dobj = createListObject();
|
||||||
dictAdd(c->db->dict,c->argv[2],dobj);
|
dictAdd(c->db->dict,c->argv[2],dobj);
|
||||||
incrRefCount(c->argv[2]);
|
incrRefCount(c->argv[2]);
|
||||||
} else if (dobj->type != REDIS_LIST) {
|
|
||||||
addReply(c,shared.wrongtypeerr);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
/* Add the element to the target list */
|
|
||||||
dstlist = dobj->ptr;
|
dstlist = dobj->ptr;
|
||||||
listAddNodeHead(dstlist,ele);
|
listAddNodeHead(dstlist,ele);
|
||||||
incrRefCount(ele);
|
incrRefCount(ele);
|
||||||
|
}
|
||||||
|
|
||||||
/* Send the element to the client as reply as well */
|
/* Send the element to the client as reply as well */
|
||||||
addReplyBulkLen(c,ele);
|
addReplyBulkLen(c,ele);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user