Flush the dirty node configuration by calling replicate for slaves or * adding the slots defined in the masters. */
| 3983 | /* Flush the dirty node configuration by calling replicate for slaves or |
| 3984 | * adding the slots defined in the masters. */ |
| 3985 | static int clusterManagerFlushNodeConfig(clusterManagerNode *node, char **err) { |
| 3986 | if (!node->dirty) return 0; |
| 3987 | redisReply *reply = NULL; |
| 3988 | int is_err = 0, success = 1; |
| 3989 | if (err != NULL) *err = NULL; |
| 3990 | if (node->replicate != NULL) { |
| 3991 | reply = CLUSTER_MANAGER_COMMAND(node, "CLUSTER REPLICATE %s", |
| 3992 | node->replicate); |
| 3993 | if (reply == NULL || (is_err = (reply->type == REDIS_REPLY_ERROR))) { |
| 3994 | if (is_err && err != NULL) { |
| 3995 | *err = zmalloc((reply->len + 1) * sizeof(char)); |
| 3996 | strcpy(*err, reply->str); |
| 3997 | } |
| 3998 | success = 0; |
| 3999 | /* If the cluster did not already joined it is possible that |
| 4000 | * the slave does not know the master node yet. So on errors |
| 4001 | * we return ASAP leaving the dirty flag set, to flush the |
| 4002 | * config later. */ |
| 4003 | goto cleanup; |
| 4004 | } |
| 4005 | } else { |
| 4006 | int added = clusterManagerAddSlots(node, err); |
| 4007 | if (!added || *err != NULL) success = 0; |
| 4008 | } |
| 4009 | node->dirty = 0; |
| 4010 | cleanup: |
| 4011 | if (reply != NULL) freeReplyObject(reply); |
| 4012 | return success; |
| 4013 | } |
| 4014 | |
| 4015 | /* Wait until the cluster configuration is consistent. */ |
| 4016 | static void clusterManagerWaitForClusterJoin(void) { |
no test coverage detected