提交 f19e267e 编写于 作者: A antirez

IPv6: bind IPv4 and IPv6 interfaces by default.

上级 90038906
......@@ -392,7 +392,7 @@ static int _anetTcpServer(char *err, int port, char *bindaddr, int af)
if ((s = socket(p->ai_family,p->ai_socktype,p->ai_protocol)) == -1)
continue;
if (AF_INET6 == af && anetV6Only(err,s) == ANET_ERR)
if (af == AF_INET6 && anetV6Only(err,s) == ANET_ERR)
goto error; /* could continue here? */
if (anetListen(err,s,p->ai_addr,p->ai_addrlen) == ANET_ERR)
......
......@@ -1431,7 +1431,18 @@ void initServer() {
* entering the loop if j == 0. */
if (server.bindaddr_count == 0) server.bindaddr[0] = NULL;
for (j = 0; j < server.bindaddr_count || j == 0; j++) {
server.ipfd[server.ipfd_count] = anetTcpServer(server.neterr,server.port,server.bindaddr[j]);
if (server.bindaddr[j] == NULL) {
/* Bind * for both IPv6 and IPv4. */
server.ipfd[0] = anetTcp6Server(server.neterr,server.port,NULL);
if (server.ipfd[0] != ANET_ERR) server.ipfd_count++;
server.ipfd[1] = anetTcpServer(server.neterr,server.port,NULL);
} else if (strchr(server.bindaddr[j],':')) {
/* Bind IPv6 address. */
server.ipfd[server.ipfd_count] = anetTcp6Server(server.neterr,server.port,server.bindaddr[j]);
} else {
/* Bind IPv4 address. */
server.ipfd[server.ipfd_count] = anetTcpServer(server.neterr,server.port,server.bindaddr[j]);
}
if (server.ipfd[server.ipfd_count] == ANET_ERR) {
redisLog(REDIS_WARNING,
"Creating Server TCP listening socket %s:%d: %s",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册