提交 2c94d80f 编写于 作者: A antirez

Fix for issue #1214 simplified.

上级 778f753d
......@@ -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]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册