MCPcopy Create free account
hub / github.com/F-Stack/f-stack / clusterReplyMultiBulkSlots

Function clusterReplyMultiBulkSlots

app/redis-6.2.6/src/cluster.c:4386–4421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4384}
4385
4386void clusterReplyMultiBulkSlots(client * c) {
4387 /* Format: 1) 1) start slot
4388 * 2) end slot
4389 * 3) 1) master IP
4390 * 2) master port
4391 * 3) node ID
4392 * 4) 1) replica IP
4393 * 2) replica port
4394 * 3) node ID
4395 * ... continued until done
4396 */
4397 clusterNode *n = NULL;
4398 int num_masters = 0, start = -1;
4399 void *slot_replylen = addReplyDeferredLen(c);
4400
4401 for (int i = 0; i <= CLUSTER_SLOTS; i++) {
4402 /* Find start node and slot id. */
4403 if (n == NULL) {
4404 if (i == CLUSTER_SLOTS) break;
4405 n = server.cluster->slots[i];
4406 start = i;
4407 continue;
4408 }
4409
4410 /* Add cluster slots info when occur different node with start
4411 * or end of slot. */
4412 if (i == CLUSTER_SLOTS || n != server.cluster->slots[i]) {
4413 addNodeReplyForClusterSlot(c, n, start, i-1);
4414 num_masters++;
4415 if (i == CLUSTER_SLOTS) break;
4416 n = server.cluster->slots[i];
4417 start = i;
4418 }
4419 }
4420 setDeferredArrayLen(c, slot_replylen, num_masters);
4421}
4422
4423void clusterCommand(client *c) {
4424 if (server.cluster_enabled == 0) {

Callers 1

clusterCommandFunction · 0.85

Calls 3

addReplyDeferredLenFunction · 0.85
setDeferredArrayLenFunction · 0.85

Tested by

no test coverage detected