Return non-zero if there is at least one master with slaves in the cluster. * Otherwise zero is returned. Used by clusterNodeSetSlotBit() to set the * MIGRATE_TO flag the when a master gets the first slot. */
| 3887 | * Otherwise zero is returned. Used by clusterNodeSetSlotBit() to set the |
| 3888 | * MIGRATE_TO flag the when a master gets the first slot. */ |
| 3889 | int clusterMastersHaveSlaves(void) { |
| 3890 | dictIterator *di = dictGetSafeIterator(g_pserver->cluster->nodes); |
| 3891 | dictEntry *de; |
| 3892 | int slaves = 0; |
| 3893 | while((de = dictNext(di)) != NULL) { |
| 3894 | clusterNode *node = (clusterNode*)dictGetVal(de); |
| 3895 | |
| 3896 | if (nodeIsSlave(node)) continue; |
| 3897 | slaves += node->numslaves; |
| 3898 | } |
| 3899 | dictReleaseIterator(di); |
| 3900 | return slaves != 0; |
| 3901 | } |
| 3902 | |
| 3903 | /* Set the slot bit and return the old value. */ |
| 3904 | int clusterNodeSetSlotBit(clusterNode *n, int slot) { |
no test coverage detected