Set the slot bit and return the old value. */
| 3843 | |
| 3844 | /* Set the slot bit and return the old value. */ |
| 3845 | int clusterNodeSetSlotBit(clusterNode *n, int slot) { |
| 3846 | int old = bitmapTestBit(n->slots,slot); |
| 3847 | bitmapSetBit(n->slots,slot); |
| 3848 | if (!old) { |
| 3849 | n->numslots++; |
| 3850 | /* When a master gets its first slot, even if it has no slaves, |
| 3851 | * it gets flagged with MIGRATE_TO, that is, the master is a valid |
| 3852 | * target for replicas migration, if and only if at least one of |
| 3853 | * the other masters has slaves right now. |
| 3854 | * |
| 3855 | * Normally masters are valid targets of replica migration if: |
| 3856 | * 1. The used to have slaves (but no longer have). |
| 3857 | * 2. They are slaves failing over a master that used to have slaves. |
| 3858 | * |
| 3859 | * However new masters with slots assigned are considered valid |
| 3860 | * migration targets if the rest of the cluster is not a slave-less. |
| 3861 | * |
| 3862 | * See https://github.com/redis/redis/issues/3043 for more info. */ |
| 3863 | if (n->numslots == 1 && clusterMastersHaveSlaves()) |
| 3864 | n->flags |= CLUSTER_NODE_MIGRATE_TO; |
| 3865 | } |
| 3866 | return old; |
| 3867 | } |
| 3868 | |
| 3869 | /* Clear the slot bit and return the old value. */ |
| 3870 | int clusterNodeClearSlotBit(clusterNode *n, int slot) { |
no test coverage detected