| 4384 | } |
| 4385 | |
| 4386 | void 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 | |
| 4423 | void clusterCommand(client *c) { |
| 4424 | if (server.cluster_enabled == 0) { |
no test coverage detected