From dcbd40cea4497936e20100f14bf7ad4b010d1803 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 23 Nov 2018 12:40:01 +0100 Subject: [PATCH] RESP3: Use new aggregate reply API in cluster.c. --- src/cluster.c | 16 ++++++++-------- src/pubsub.c | 6 +++--- src/sort.c | 2 +- src/t_list.c | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index b253efe1f..fb25405fe 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -4126,7 +4126,7 @@ void clusterReplyMultiBulkSlots(client *c) { */ int num_masters = 0; - void *slot_replylen = addDeferredMultiBulkLength(c); + void *slot_replylen = addReplyDeferredLen(c); dictEntry *de; dictIterator *di = dictGetSafeIterator(server.cluster->nodes); @@ -4146,7 +4146,7 @@ void clusterReplyMultiBulkSlots(client *c) { } if (start != -1 && (!bit || j == CLUSTER_SLOTS-1)) { int nested_elements = 3; /* slots (2) + master addr (1). */ - void *nested_replylen = addDeferredMultiBulkLength(c); + void *nested_replylen = addReplyDeferredLen(c); if (bit && j == CLUSTER_SLOTS-1) j++; @@ -4162,7 +4162,7 @@ void clusterReplyMultiBulkSlots(client *c) { start = -1; /* First node reply position is always the master */ - addReplyMultiBulkLen(c, 3); + addReplyArrayLen(c, 3); addReplyBulkCString(c, node->ip); addReplyLongLong(c, node->port); addReplyBulkCBuffer(c, node->name, CLUSTER_NAMELEN); @@ -4172,19 +4172,19 @@ void clusterReplyMultiBulkSlots(client *c) { /* This loop is copy/pasted from clusterGenNodeDescription() * with modifications for per-slot node aggregation */ if (nodeFailed(node->slaves[i])) continue; - addReplyMultiBulkLen(c, 3); + addReplyArrayLen(c, 3); addReplyBulkCString(c, node->slaves[i]->ip); addReplyLongLong(c, node->slaves[i]->port); addReplyBulkCBuffer(c, node->slaves[i]->name, CLUSTER_NAMELEN); nested_elements++; } - setDeferredMultiBulkLength(c, nested_replylen, nested_elements); + setDeferredArrayLen(c, nested_replylen, nested_elements); num_masters++; } } } dictReleaseIterator(di); - setDeferredMultiBulkLength(c, slot_replylen, num_masters); + setDeferredArrayLen(c, slot_replylen, num_masters); } void clusterCommand(client *c) { @@ -4548,7 +4548,7 @@ NULL keys = zmalloc(sizeof(robj*)*maxkeys); numkeys = getKeysInSlot(slot, keys, maxkeys); - addReplyMultiBulkLen(c,numkeys); + addReplyArrayLen(c,numkeys); for (j = 0; j < numkeys; j++) { addReplyBulk(c,keys[j]); decrRefCount(keys[j]); @@ -4627,7 +4627,7 @@ NULL return; } - addReplyMultiBulkLen(c,n->numslaves); + addReplyArrayLen(c,n->numslaves); for (j = 0; j < n->numslaves; j++) { sds ni = clusterGenNodeDescription(n->slaves[j]); addReplyBulkCString(c,ni); diff --git a/src/pubsub.c b/src/pubsub.c index 859eb46a3..c407cadf2 100644 --- a/src/pubsub.c +++ b/src/pubsub.c @@ -343,7 +343,7 @@ NULL long mblen = 0; void *replylen; - replylen = addDeferredMultiBulkLength(c); + replylen = addReplyDeferredLen(c); while((de = dictNext(di)) != NULL) { robj *cobj = dictGetKey(de); sds channel = cobj->ptr; @@ -356,12 +356,12 @@ NULL } } dictReleaseIterator(di); - setDeferredMultiBulkLength(c,replylen,mblen); + setDeferredArrayLen(c,replylen,mblen); } else if (!strcasecmp(c->argv[1]->ptr,"numsub") && c->argc >= 2) { /* PUBSUB NUMSUB [Channel_1 ... Channel_N] */ int j; - addReplyMultiBulkLen(c,(c->argc-2)*2); + addReplyArrayLen(c,(c->argc-2)*2); for (j = 2; j < c->argc; j++) { list *l = dictFetchValue(server.pubsub_channels,c->argv[j]); diff --git a/src/sort.c b/src/sort.c index 4b300d868..322f02726 100644 --- a/src/sort.c +++ b/src/sort.c @@ -505,7 +505,7 @@ void sortCommand(client *c) { addReplyError(c,"One or more scores can't be converted into double"); } else if (storekey == NULL) { /* STORE option not specified, sent the sorting result to client */ - addReplyMultiBulkLen(c,outputlen); + addReplyArrayLen(c,outputlen); for (j = start; j <= end; j++) { listNode *ln; listIter li; diff --git a/src/t_list.c b/src/t_list.c index c8f4703d5..dd4ec9537 100644 --- a/src/t_list.c +++ b/src/t_list.c @@ -421,7 +421,7 @@ void lrangeCommand(client *c) { rangelen = (end-start)+1; /* Return the result in form of a multi-bulk reply */ - addReplyMultiBulkLen(c,rangelen); + addReplyArrayLen(c,rangelen); if (o->encoding == OBJ_ENCODING_QUICKLIST) { listTypeIterator *iter = listTypeInitIterator(o, start, LIST_TAIL); @@ -639,10 +639,10 @@ int serveClientBlockedOnList(client *receiver, robj *key, robj *dstkey, redisDb db->id,argv,2,PROPAGATE_AOF|PROPAGATE_REPL); /* BRPOP/BLPOP */ - addReplyMultiBulkLen(receiver,2); + addReplyArrayLen(receiver,2); addReplyBulk(receiver,key); addReplyBulk(receiver,value); - + /* Notify event. */ char *event = (where == LIST_HEAD) ? "lpop" : "rpop"; notifyKeyspaceEvent(NOTIFY_LIST,event,key,receiver->db->id); @@ -704,7 +704,7 @@ void blockingPopGenericCommand(client *c, int where) { robj *value = listTypePop(o,where); serverAssert(value != NULL); - addReplyMultiBulkLen(c,2); + addReplyArrayLen(c,2); addReplyBulk(c,c->argv[j]); addReplyBulk(c,value); decrRefCount(value);