mirror of
https://github.com/fluencelabs/redis
synced 2025-04-14 13:16:03 +00:00
Cluster: bulk-accept new nodes connections.
The same change was operated for normal client connections. This is important for Cluster as well, since when a node rejoins the cluster, when a partition heals or after a restart, it gets flooded with new connection attempts by all the other nodes trying to form a full mesh again.
This commit is contained in:
parent
3625b52791
commit
8a170c817d
@ -492,17 +492,22 @@ void freeClusterLink(clusterLink *link) {
|
|||||||
zfree(link);
|
zfree(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MAX_CLUSTER_ACCEPTS_PER_CALL 1000
|
||||||
void clusterAcceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
|
void clusterAcceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
|
||||||
int cport, cfd;
|
int cport, cfd;
|
||||||
|
int max = MAX_CLUSTER_ACCEPTS_PER_CALL;
|
||||||
char cip[REDIS_IP_STR_LEN];
|
char cip[REDIS_IP_STR_LEN];
|
||||||
clusterLink *link;
|
clusterLink *link;
|
||||||
REDIS_NOTUSED(el);
|
REDIS_NOTUSED(el);
|
||||||
REDIS_NOTUSED(mask);
|
REDIS_NOTUSED(mask);
|
||||||
REDIS_NOTUSED(privdata);
|
REDIS_NOTUSED(privdata);
|
||||||
|
|
||||||
|
while(max--) {
|
||||||
cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport);
|
cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport);
|
||||||
if (cfd == ANET_ERR) {
|
if (cfd == ANET_ERR) {
|
||||||
redisLog(REDIS_VERBOSE,"Accepting cluster node: %s", server.neterr);
|
if (errno != EWOULDBLOCK)
|
||||||
|
redisLog(REDIS_VERBOSE,
|
||||||
|
"Accepting cluster node: %s", server.neterr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
anetNonBlock(NULL,cfd);
|
anetNonBlock(NULL,cfd);
|
||||||
@ -518,6 +523,7 @@ void clusterAcceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
|
|||||||
link = createClusterLink(NULL);
|
link = createClusterLink(NULL);
|
||||||
link->fd = cfd;
|
link->fd = cfd;
|
||||||
aeCreateFileEvent(server.el,cfd,AE_READABLE,clusterReadHandler,link);
|
aeCreateFileEvent(server.el,cfd,AE_READABLE,clusterReadHandler,link);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user