Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
d0e32741
Commit
d0e32741
authored
Sep 04, 2013
by
antirez
Browse files
Cluster: don't add an handshake node for the same ip:port pair multiple times.
parent
72587e6c
Changes
1
Show whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
d0e32741
...
@@ -674,6 +674,24 @@ void clearNodeFailureIfNeeded(clusterNode *node) {
...
@@ -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.
/* Process the gossip section of PING or PONG packets.
* Note that this function assumes that the packet is already sanity-checked
* 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
* by the caller, not in the content of the gossip section, but in the
...
@@ -736,7 +754,9 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
...
@@ -736,7 +754,9 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
* Note that we require that the sender of this gossip message
* Note that we require that the sender of this gossip message
* is a well known node in our cluster, otherwise we risk
* is a well known node in our cluster, otherwise we risk
* joining another cluster. */
* joining another cluster. */
if (sender && !(flags & REDIS_NODE_NOADDR)) {
if (sender && !(flags & REDIS_NODE_NOADDR) &&
!clusterHandshakeInProgress(g->ip,ntohs(g->port)))
{
clusterNode *newnode;
clusterNode *newnode;
redisLog(REDIS_DEBUG,"Adding the new node");
redisLog(REDIS_DEBUG,"Adding the new node");
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment