diff options
author | antirez <antirez@gmail.com> | 2015-01-21 15:55:53 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-01-22 10:35:08 +0100 |
commit | 5130c2536b66402ca17b582d52960e11eac7dde7 (patch) | |
tree | bbab9d70d66298924fe9fad1f13ad425542f1131 | |
parent | 98f56f8f9ea8655e31797fbffb7f5419070a1d5f (diff) | |
download | redis-5130c2536b66402ca17b582d52960e11eac7dde7.tar.gz |
Cluster: set the slaves->slaveof filed to NULL when master is freed.
Related to issue #2289.
-rw-r--r-- | src/cluster.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cluster.c b/src/cluster.c index c3cf06026..84bf4fa89 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -821,6 +821,14 @@ int clusterCountNonFailingSlaves(clusterNode *n) { void freeClusterNode(clusterNode *n) { sds nodename; + int j; + + /* If the node is a master with associated slaves, we have to set + * all the slaves->slaveof fields to NULL (unknown). */ + if (nodeIsMaster(n)) { + for (j = 0; j < n->numslaves; j++) + n->slaves[j]->slaveof = NULL; + } nodename = sdsnewlen(n->name, REDIS_CLUSTER_NAMELEN); redisAssert(dictDelete(server.cluster->nodes,nodename) == DICT_OK); |