MCPcopy Create free account
hub / github.com/F-Stack/f-stack / clusterManagerFlushNodeConfig

Function clusterManagerFlushNodeConfig

app/redis-6.2.6/src/redis-cli.c:3985–4013  ·  view source on GitHub ↗

Flush the dirty node configuration by calling replicate for slaves or * adding the slots defined in the masters. */

Source from the content-addressed store, hash-verified

3983/* Flush the dirty node configuration by calling replicate for slaves or
3984 * adding the slots defined in the masters. */
3985static 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;
4010cleanup:
4011 if (reply != NULL) freeReplyObject(reply);
4012 return success;
4013}
4014
4015/* Wait until the cluster configuration is consistent. */
4016static void clusterManagerWaitForClusterJoin(void) {

Callers 1

Calls 3

zmallocFunction · 0.85
clusterManagerAddSlotsFunction · 0.85
freeReplyObjectFunction · 0.85

Tested by

no test coverage detected