diff options
author | antirez <antirez@gmail.com> | 2013-08-21 11:36:09 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-08-21 11:41:35 +0200 |
commit | 2c94d80f58f2794ae3028a48ebdcc92e25b83e03 (patch) | |
tree | 7cbd77b9815d3d13b663b5b90aef043e907fa160 | |
parent | 778f753deb2f856ff57dbedf6df7dfd2a2db157d (diff) | |
download | redis-2c94d80f58f2794ae3028a48ebdcc92e25b83e03.tar.gz |
Fix for issue #1214 simplified.
-rw-r--r-- | src/redis.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/redis.c b/src/redis.c index 54562ff37..2a2ce83c0 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1436,7 +1436,6 @@ void adjustOpenFilesLimit(void) { void initServer() { int j; - int ip_count; signal(SIGHUP, SIG_IGN); signal(SIGPIPE, SIG_IGN); @@ -1468,19 +1467,18 @@ void initServer() { if (server.bindaddr_count == 0) server.bindaddr[0] = NULL; for (j = 0; j < server.bindaddr_count || j == 0; j++) { if (server.bindaddr[j] == NULL) { - /* Bind * for both IPv6 and IPv4. - * Should consider that someone only has IPV6 and someone only get IPV4 */ - ip_count = 0; - server.ipfd[ip_count] = anetTcp6Server(server.neterr,server.port,NULL); - if (server.ipfd[ip_count] != ANET_ERR) ip_count++; - - server.ipfd[ip_count] = anetTcpServer(server.neterr,server.port,NULL); - if(server.ipfd[ip_count] != ANET_ERR ) ip_count++; - - /* It should be ip_count plus one - * because out of this branch, the server.ipfd_count would increase */ - server.ipfd_count += (ip_count - 1); - + /* Bind * for both IPv6 and IPv4, we enter here only if + * server.bindaddr_count == 0, so we try to bind and then + * break to exit the loop ASAP. */ + server.ipfd[server.ipfd_count] = + anetTcp6Server(server.neterr,server.port,NULL); + if (server.ipfd[server.ipfd_count] != ANET_ERR) + server.ipfd_count++; + server.ipfd[server.ipfd_count] = + anetTcpServer(server.neterr,server.port,NULL); + if(server.ipfd[server.ipfd_count] != ANET_ERR) + server.ipfd_count++; + break; } else if (strchr(server.bindaddr[j],':')) { /* Bind IPv6 address. */ server.ipfd[server.ipfd_count] = anetTcp6Server(server.neterr,server.port,server.bindaddr[j]); |