Skip to content

Commit

Permalink
Use listenToPort() in cluster.c as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Aug 22, 2013
1 parent 4f310e0 commit 81a6a96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void clusterSaveConfigOrDie(void) {
}

void clusterInit(void) {
int saveconf = 0, j;
int saveconf = 0;

server.cluster = zmalloc(sizeof(clusterState));
server.cluster->myself = NULL;
Expand All @@ -252,25 +252,16 @@ void clusterInit(void) {
saveconf = 1;
}
if (saveconf) clusterSaveConfigOrDie();
/* We need a listening TCP port for our cluster messaging needs */

/* We need a listening TCP port for our cluster messaging needs. */
server.cfd_count = 0;
if (server.bindaddr_count == 0) server.bindaddr[0] = NULL;
for (j = 0; j < server.bindaddr_count || j == 0; j++) {
server.cfd[j] = anetTcpServer(
server.neterr, server.port+REDIS_CLUSTER_PORT_INCR,
server.bindaddr[j]);
if (server.cfd[j] == -1) {
redisLog(REDIS_WARNING,
"Opening cluster listening TCP socket %s:%d: %s",
server.bindaddr[j] ? server.bindaddr[j] : "*",
server.port+REDIS_CLUSTER_PORT_INCR,
server.neterr);
exit(1);
}
if (aeCreateFileEvent(server.el, server.cfd[j], AE_READABLE,
clusterAcceptHandler, NULL) == AE_ERR) redisPanic("Unrecoverable error creating Redis Cluster file event.");
server.cfd_count++;
if (listenToPort(server.port+REDIS_CLUSTER_PORT_INCR,
server.cfd,&server.cfd_count) == REDIS_ERR)
{
exit(1);
}

/* The slots -> keys map is a sorted set. Init it. */
server.cluster->slots_to_keys = zslCreate();
}

Expand Down
1 change: 1 addition & 0 deletions src/redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,7 @@ int getClientLimitClassByName(char *name);
char *getClientLimitClassName(int class);
void flushSlavesOutputBuffers(void);
void disconnectSlaves(void);
int listenToPort(int port, int *fds, int *count);

#ifdef __GNUC__
void addReplyErrorFormat(redisClient *c, const char *fmt, ...)
Expand Down

0 comments on commit 81a6a96

Please sign in to comment.