提交 d0e32741 编写于 作者: A antirez

Cluster: don't add an handshake node for the same ip:port pair multiple times.

上级 72587e6c
......@@ -674,6 +674,24 @@ void clearNodeFailureIfNeeded(clusterNode *node) {
}
}
/* Return true if we already have a node in HANDSHAKE state matching the
* specified ip address and port number. This function is used in order to
* avoid adding a new handshake node for the same address multiple times. */
int clusterHandshakeInProgress(char *ip, int port) {
dictIterator *di;
dictEntry *de;
di = dictGetSafeIterator(server.cluster->nodes);
while((de = dictNext(di)) != NULL) {
clusterNode *node = dictGetVal(de);
if (!(node->flags & REDIS_NODE_HANDSHAKE)) continue;
if (!strcasecmp(node->ip,ip) && node->port == port) break;
}
dictReleaseIterator(di);
return de != NULL;
}
/* Process the gossip section of PING or PONG packets.
* Note that this function assumes that the packet is already sanity-checked
* by the caller, not in the content of the gossip section, but in the
......@@ -736,7 +754,9 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
* Note that we require that the sender of this gossip message
* is a well known node in our cluster, otherwise we risk
* joining another cluster. */
if (sender && !(flags & REDIS_NODE_NOADDR)) {
if (sender && !(flags & REDIS_NODE_NOADDR) &&
!clusterHandshakeInProgress(g->ip,ntohs(g->port)))
{
clusterNode *newnode;
redisLog(REDIS_DEBUG,"Adding the new node");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册