Commit d01a6bb3 authored by antirez's avatar antirez
Browse files

fixes to configuration loading and saving. However there is to still fix the...

fixes to configuration loading and saving. However there is to still fix the logic for reconnection/behavior of nodes after a restart.
parent 92690d29
...@@ -86,6 +86,8 @@ int clusterLoadConfig(char *filename) { ...@@ -86,6 +86,8 @@ int clusterLoadConfig(char *filename) {
n->flags |= REDIS_NODE_HANDSHAKE; n->flags |= REDIS_NODE_HANDSHAKE;
} else if (!strcasecmp(s,"noaddr")) { } else if (!strcasecmp(s,"noaddr")) {
n->flags |= REDIS_NODE_NOADDR; n->flags |= REDIS_NODE_NOADDR;
} else if (!strcasecmp(s,"noflags")) {
/* nothing to do */
} else { } else {
redisPanic("Unknown flag in redis cluster config file"); redisPanic("Unknown flag in redis cluster config file");
} }
...@@ -524,7 +526,8 @@ int clusterProcessPacket(clusterLink *link) { ...@@ -524,7 +526,8 @@ int clusterProcessPacket(clusterLink *link) {
/* Anyway reply with a PONG */ /* Anyway reply with a PONG */
clusterSendPing(link,CLUSTERMSG_TYPE_PONG); clusterSendPing(link,CLUSTERMSG_TYPE_PONG);
} else if (type == CLUSTERMSG_TYPE_PONG) { } else if (type == CLUSTERMSG_TYPE_PONG) {
int update = 0; int update_state = 0;
int update_config = 0;
redisLog(REDIS_DEBUG,"Pong packet received: %p", link->node); redisLog(REDIS_DEBUG,"Pong packet received: %p", link->node);
if (link->node) { if (link->node) {
...@@ -545,6 +548,7 @@ int clusterProcessPacket(clusterLink *link) { ...@@ -545,6 +548,7 @@ int clusterProcessPacket(clusterLink *link) {
redisLog(REDIS_DEBUG,"Handshake with node %.40s completed.", redisLog(REDIS_DEBUG,"Handshake with node %.40s completed.",
link->node->name); link->node->name);
link->node->flags &= ~REDIS_NODE_HANDSHAKE; link->node->flags &= ~REDIS_NODE_HANDSHAKE;
update_config = 1;
} else if (memcmp(link->node->name,hdr->sender, } else if (memcmp(link->node->name,hdr->sender,
REDIS_CLUSTER_NAMELEN) != 0) REDIS_CLUSTER_NAMELEN) != 0)
{ {
...@@ -554,6 +558,7 @@ int clusterProcessPacket(clusterLink *link) { ...@@ -554,6 +558,7 @@ int clusterProcessPacket(clusterLink *link) {
redisLog(REDIS_DEBUG,"PONG contains mismatching sender ID"); redisLog(REDIS_DEBUG,"PONG contains mismatching sender ID");
link->node->flags |= REDIS_NODE_NOADDR; link->node->flags |= REDIS_NODE_NOADDR;
freeClusterLink(link); freeClusterLink(link);
update_config = 1;
/* FIXME: remove this node if we already have it. /* FIXME: remove this node if we already have it.
* *
* If we already have it but the IP is different, use * If we already have it but the IP is different, use
...@@ -599,7 +604,7 @@ int clusterProcessPacket(clusterLink *link) { ...@@ -599,7 +604,7 @@ int clusterProcessPacket(clusterLink *link) {
server.cluster.slots[j]->flags & REDIS_NODE_FAIL) server.cluster.slots[j]->flags & REDIS_NODE_FAIL)
{ {
server.cluster.slots[j] = sender; server.cluster.slots[j] = sender;
update = 1; update_state = update_config = 1;
} }
} }
} }
...@@ -610,10 +615,8 @@ int clusterProcessPacket(clusterLink *link) { ...@@ -610,10 +615,8 @@ int clusterProcessPacket(clusterLink *link) {
clusterProcessGossipSection(hdr,link); clusterProcessGossipSection(hdr,link);
/* Update the cluster state if needed */ /* Update the cluster state if needed */
if (update) { if (update_state) clusterUpdateState();
clusterUpdateState(); if (update_config) clusterSaveConfigOrDie();
clusterSaveConfigOrDie();
}
} else if (type == CLUSTERMSG_TYPE_FAIL && sender) { } else if (type == CLUSTERMSG_TYPE_FAIL && sender) {
clusterNode *failing; clusterNode *failing;
...@@ -1059,8 +1062,8 @@ sds clusterGenNodesDescription(void) { ...@@ -1059,8 +1062,8 @@ sds clusterGenNodesDescription(void) {
start = -1; start = -1;
} }
} }
ci = sdscatlen(ci,"\n",1);
} }
ci = sdscatlen(ci,"\n",1);
dictReleaseIterator(di); dictReleaseIterator(di);
return ci; return ci;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment