From 35f05c66b6ae9cd0e81672ce67942a25589d2c2e Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 14 Mar 2013 16:42:56 +0100 Subject: [PATCH] Cluster: handle FAILOVER_AUTH_ACK messages. That's trivial as we just need to increment the count of masters that received with an ACK. --- src/cluster.c | 9 ++++++++- src/redis.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cluster.c b/src/cluster.c index 67e90773f..e614d5d49 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -794,7 +794,8 @@ int clusterProcessPacket(clusterLink *link) { ntohl(hdr->data.publish.msg.channel_len) + ntohl(hdr->data.publish.msg.message_len); if (totlen != explen) return 1; - } else if (type == CLUSTERMSG_TYPE_FAILOVER_AUTH_REQUEST) { + } else if (type == CLUSTERMSG_TYPE_FAILOVER_AUTH_REQUEST || + type == CLUSTERMSG_TYPE_FAILOVER_AUTH_ACK) { uint32_t explen = sizeof(clusterMsg)-sizeof(union clusterMsgData); if (totlen != explen) return 1; @@ -876,6 +877,12 @@ int clusterProcessPacket(clusterLink *link) { /* If we are not a master, ignore that message at all. */ if (!(server.cluster->myself->flags & REDIS_NODE_MASTER)) return 0; clusterSendFailoverAuthIfNeeded(sender); + } else if (type == CLUSTERMSG_TYPE_FAILOVER_AUTH_ACK) { + if (!sender) return 0; /* We don't know that node. */ + /* If this is a master, increment the number of acknowledges + * we received so far. */ + if (sender->flags & REDIS_NODE_MASTER) + server.cluster->failover_auth_count++; } /* Update our info about the node */ diff --git a/src/redis.h b/src/redis.h index 5a2392c86..2c662d6d6 100644 --- a/src/redis.h +++ b/src/redis.h @@ -595,6 +595,7 @@ typedef struct { #define CLUSTERMSG_TYPE_FAIL 3 /* Mark node xxx as failing */ #define CLUSTERMSG_TYPE_PUBLISH 4 /* Pub/Sub Publish propagation */ #define CLUSTERMSG_TYPE_FAILOVER_AUTH_REQUEST 5 /* May I failover? */ +#define CLUSTERMSG_TYPE_FAILOVER_AUTH_ACK 6 /* Yes, you can failover. */ /* Initially we don't know our "name", but we'll find it once we connect * to the first node, using the getsockname() function. Then we'll use this