summaryrefslogtreecommitdiff
path: root/src/cluster.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-01-21 15:55:53 +0100
committerantirez <antirez@gmail.com>2015-01-21 15:55:53 +0100
commit59ad6ac5feac4f6760144861b723a51383a0f19b (patch)
tree6917b6ab5269993e8ccb892084b3c761ae4764ba /src/cluster.c
parent491d57abaae7ddb9f32951acc3c38e27f3638b90 (diff)
downloadredis-59ad6ac5feac4f6760144861b723a51383a0f19b.tar.gz
Cluster: set the slaves->slaveof filed to NULL when master is freed.
Related to issue #2289.
Diffstat (limited to 'src/cluster.c')
-rw-r--r--src/cluster.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cluster.c b/src/cluster.c
index ec6901e8f..5135cdaa5 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);