From d426ada891bfe8b1e35d667f4357c14fb357c9af Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 25 Sep 2013 11:53:35 +0200 Subject: [PATCH] Cluster: broadcast currentEpoch and configEpoch in packets header. --- src/cluster.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cluster.c b/src/cluster.c index 43a8133f..f1cdb915 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1321,12 +1321,20 @@ void clusterBuildMessageHdr(clusterMsg *hdr, int type) { hdr->flags = htons(server.cluster->myself->flags); hdr->state = server.cluster->state; + /* Set the currentEpoch and configEpochs. Note that configEpoch is + * set to the master configEpoch if this node is a slave. */ + hdr->currentEpoch = htonu64(server.cluster->currentEpoch); + if (server.cluster->myself->flags & REDIS_NODE_SLAVE) + hdr->configEpoch = htonu64(server.cluster->myself->slaveof->configEpoch); + else + hdr->configEpoch = htonu64(server.cluster->myself->configEpoch); + if (type == CLUSTERMSG_TYPE_FAIL) { totlen = sizeof(clusterMsg)-sizeof(union clusterMsgData); totlen += sizeof(clusterMsgDataFail); } hdr->totlen = htonl(totlen); - /* For PING, PONG, and MEET, fixing the totlen field is up to the caller */ + /* For PING, PONG, and MEET, fixing the totlen field is up to the caller. */ } /* Send a PING or PONG packet to the specified node, making sure to add enough