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. */
| 3828 | * Otherwise zero is returned. Used by clusterNodeSetSlotBit() to set the |
| 3829 | * MIGRATE_TO flag the when a master gets the first slot. */ |
| 3830 | int clusterMastersHaveSlaves(void) { |
| 3831 | dictIterator *di = dictGetSafeIterator(server.cluster->nodes); |
| 3832 | dictEntry *de; |
| 3833 | int slaves = 0; |
| 3834 | while((de = dictNext(di)) != NULL) { |
| 3835 | clusterNode *node = dictGetVal(de); |
| 3836 | |
| 3837 | if (nodeIsSlave(node)) continue; |
| 3838 | slaves += node->numslaves; |
| 3839 | } |
| 3840 | dictReleaseIterator(di); |
| 3841 | return slaves != 0; |
| 3842 | } |
| 3843 | |
| 3844 | /* Set the slot bit and return the old value. */ |
| 3845 | int clusterNodeSetSlotBit(clusterNode *n, int slot) { |
no test coverage detected