diff options
author | antirez <antirez@gmail.com> | 2013-04-11 18:19:48 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-05-03 15:41:34 +0200 |
commit | a120560f700a1cd59bcd52568e113c03e2da31a3 (patch) | |
tree | f7e71381033f64ca6a636b64fba01d656e018bb8 | |
parent | 8a51c067adf56996644a4fadab10d9ce4f05b370 (diff) | |
download | redis-a120560f700a1cd59bcd52568e113c03e2da31a3.tar.gz |
Cluster: process config from PING packets as we do for PONG.
Also clusterBroadcastPing() was renamed into clusterBroadcastPong()
that's what the function is actually doing.
-rw-r--r-- | src/cluster.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/cluster.c b/src/cluster.c index 972484449..b3c3da914 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -807,8 +807,9 @@ int clusterProcessPacket(clusterLink *link) { if (totlen != explen) return 1; } - /* Ready to process the packet. Dispatch by type. */ + /* Process packets by type. */ sender = clusterLookupNode(hdr->sender); + if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_MEET) { int update_config = 0; redisLog(REDIS_DEBUG,"Ping packet received: %p", (void*)link->node); @@ -835,11 +836,16 @@ int clusterProcessPacket(clusterLink *link) { /* Update config if needed */ if (update_config) clusterSaveConfigOrDie(); - } else if (type == CLUSTERMSG_TYPE_PONG) { + } + + /* PING or PONG: process config information. */ + if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_PONG) { int update_state = 0; int update_config = 0; - redisLog(REDIS_DEBUG,"Pong packet received: %p", (void*)link->node); + redisLog(REDIS_DEBUG,"%s packet received: %p", + type == CLUSTERMSG_TYPE_PING ? "ping" : "pong", + (void*)link->node); if (link->node) { if (link->node->flags & REDIS_NODE_HANDSHAKE) { /* If we already have this node, try to change the @@ -1253,14 +1259,13 @@ void clusterSendPing(clusterLink *link, int type) { clusterSendMessage(link,buf,totlen); } -/* Send a PING packet to every connected node that's not in handshake state. +/* Send a PONG packet to every connected node that's not in handshake state. * - * Usually cluster nodes will ping just another node every second, however - * in Redis Cluster pings are not just used for failure detection, but also - * to carry important configuration informations. So broadcasting a ping is + * In Redis Cluster pings are not just used for failure detection, but also + * to carry important configuration informations. So broadcasting a pong is * useful when something changes in the configuration and we want to make * the cluster aware ASAP (for instance after a slave promotion). */ -void clusterBroadcastPing(void) { +void clusterBroadcastPong(void) { dictIterator *di; dictEntry *de; @@ -1478,9 +1483,9 @@ void clusterHandleSlaveFailover(void) { } } - /* 3) Ping all the other nodes so that they can update the state + /* 3) Pong all the other nodes so that they can update the state * accordingly and detect that we switched to master role. */ - clusterBroadcastPing(); + clusterBroadcastPong(); /* 4) Update state and save config. */ clusterUpdateState(); |