Set the slot bit and return the old value. */
| 3902 | |
| 3903 | /* Set the slot bit and return the old value. */ |
| 3904 | int clusterNodeSetSlotBit(clusterNode *n, int slot) { |
| 3905 | int old = bitmapTestBit(n->slots,slot); |
| 3906 | bitmapSetBit(n->slots,slot); |
| 3907 | if (!old) { |
| 3908 | n->numslots++; |
| 3909 | /* When a master gets its first slot, even if it has no slaves, |
| 3910 | * it gets flagged with MIGRATE_TO, that is, the master is a valid |
| 3911 | * target for replicas migration, if and only if at least one of |
| 3912 | * the other masters has slaves right now. |
| 3913 | * |
| 3914 | * Normally masters are valid targets of replica migration if: |
| 3915 | * 1. The used to have slaves (but no longer have). |
| 3916 | * 2. They are slaves failing over a master that used to have slaves. |
| 3917 | * |
| 3918 | * However new masters with slots assigned are considered valid |
| 3919 | * migration targets if the rest of the cluster is not a slave-less. |
| 3920 | * |
| 3921 | * See https://github.com/redis/redis/issues/3043 for more info. */ |
| 3922 | if (n->numslots == 1 && clusterMastersHaveSlaves()) |
| 3923 | n->flags |= CLUSTER_NODE_MIGRATE_TO; |
| 3924 | } |
| 3925 | return old; |
| 3926 | } |
| 3927 | |
| 3928 | /* Clear the slot bit and return the old value. */ |
| 3929 | int clusterNodeClearSlotBit(clusterNode *n, int slot) { |
no test coverage detected