mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
IPv6: bind IPv4 and IPv6 interfaces by default.
This commit is contained in:
parent
90038906f4
commit
f19e267e9a
@ -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)
|
||||
|
11
src/redis.c
11
src/redis.c
@ -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++) {
|
||||
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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user