Skip to content

Commit

Permalink
fff
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-binbin committed Nov 5, 2023
1 parent 30a775e commit 520df35
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -5801,7 +5801,25 @@ void clusterReplyMultiBulkSlots(client * c) {
*/
clusterNode *n = NULL;
int num_masters = 0, start = -1;
void *slot_replylen = addReplyDeferredLen(c);

for (int i = 0; i <= CLUSTER_SLOTS; i++) {
/* Find start node and slot id. */
if (n == NULL) {
if (i == CLUSTER_SLOTS) break;
n = server.cluster->slots[i];
start = i;
continue;
}

if (i == CLUSTER_SLOTS || n != server.cluster->slots[i]) {
num_masters++;
if (i == CLUSTER_SLOTS) break;
n = server.cluster->slots[i];
start = i;
}
}

addReplyMapLen(c, num_masters);

for (int i = 0; i <= CLUSTER_SLOTS; i++) {
/* Find start node and slot id. */
Expand All @@ -5816,13 +5834,14 @@ void clusterReplyMultiBulkSlots(client * c) {
* or end of slot. */
if (i == CLUSTER_SLOTS || n != server.cluster->slots[i]) {
addNodeReplyForClusterSlot(c, n, start, i-1);
num_masters++;
num_masters--;
if (i == CLUSTER_SLOTS) break;
n = server.cluster->slots[i];
start = i;
}
}
setDeferredArrayLen(c, slot_replylen, num_masters);

serverAssert(c, num_masters == 0);
}

sds genClusterInfoString(void) {
Expand Down

0 comments on commit 520df35

Please sign in to comment.