summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2017-04-14 10:40:22 +0200
committerantirez <antirez@gmail.com>2017-04-14 11:01:22 +0200
commit8c829d9e4323b3636afa43d0ad8eb1ce2397c3f9 (patch)
treed149197b4b73449c5d26bf5a5c9841f99789663d
parent6878a3fedd8b15ed3c0602d15940007ebd240f22 (diff)
downloadredis-8c829d9e4323b3636afa43d0ad8eb1ce2397c3f9.tar.gz
Cluster: fix gossip section ping/pong times encoding.
The gossip section times are 32 bit, so cannot store the milliseconds time but just the seconds approximation, which is good enough for our uses. At the same time however, when comparing the gossip section times of other nodes with our node's view, we need to convert back to milliseconds. Related to #3929. Without this change the patch to reduce the traffic in the bus message does not work.
-rw-r--r--src/cluster.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cluster.c b/src/cluster.c
index d1d839cba..cae63e924 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -1362,7 +1362,8 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
node->ping_sent == 0 &&
clusterNodeFailureReportsCount(node) == 0)
{
- uint32_t pongtime = ntohl(g->pong_received);
+ mstime_t pongtime = ntohl(g->pong_received);
+ pongtime *= 1000; /* Convert back to milliseconds. */
if (pongtime > node->pong_received) {
node->pong_received = pongtime;
}
@@ -2353,8 +2354,8 @@ void clusterSendPing(clusterLink *link, int type) {
freshnodes--;
gossip = &(hdr->data.ping.gossip[gossipcount]);
memcpy(gossip->nodename,this->name,CLUSTER_NAMELEN);
- gossip->ping_sent = htonl(this->ping_sent);
- gossip->pong_received = htonl(this->pong_received);
+ gossip->ping_sent = htonl(this->ping_sent/1000);
+ gossip->pong_received = htonl(this->pong_received/1000);
memcpy(gossip->ip,this->ip,sizeof(this->ip));
gossip->port = htons(this->port);
gossip->cport = htons(this->cport);