mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Bind both IPv4 and IPv6 or exit with an error by default.
Thanks to @tushar2708 for the PR. I applied a slightly different fix. Thanks to @cespare for reporting. Close #3024 Close #3020
This commit is contained in:
parent
0bb787d3ad
commit
c77b95fd01
18
src/server.c
18
src/server.c
@ -1789,17 +1789,19 @@ int listenToPort(int port, int *fds, int *count) {
|
|||||||
if (fds[*count] != ANET_ERR) {
|
if (fds[*count] != ANET_ERR) {
|
||||||
anetNonBlock(NULL,fds[*count]);
|
anetNonBlock(NULL,fds[*count]);
|
||||||
(*count)++;
|
(*count)++;
|
||||||
|
|
||||||
|
/* Bind the IPv4 address as well. */
|
||||||
|
fds[*count] = anetTcpServer(server.neterr,port,NULL,
|
||||||
|
server.tcp_backlog);
|
||||||
|
if (fds[*count] != ANET_ERR) {
|
||||||
|
anetNonBlock(NULL,fds[*count]);
|
||||||
|
(*count)++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fds[*count] = anetTcpServer(server.neterr,port,NULL,
|
/* Exit the loop if we were able to bind * on IPv4 and IPv6,
|
||||||
server.tcp_backlog);
|
|
||||||
if (fds[*count] != ANET_ERR) {
|
|
||||||
anetNonBlock(NULL,fds[*count]);
|
|
||||||
(*count)++;
|
|
||||||
}
|
|
||||||
/* Exit the loop if we were able to bind * on IPv4 or IPv6,
|
|
||||||
* otherwise fds[*count] will be ANET_ERR and we'll print an
|
* otherwise fds[*count] will be ANET_ERR and we'll print an
|
||||||
* error and return to the caller with an error. */
|
* error and return to the caller with an error. */
|
||||||
if (*count) break;
|
if (*count == 2) break;
|
||||||
} else if (strchr(server.bindaddr[j],':')) {
|
} else if (strchr(server.bindaddr[j],':')) {
|
||||||
/* Bind IPv6 address. */
|
/* Bind IPv6 address. */
|
||||||
fds[*count] = anetTcp6Server(server.neterr,port,server.bindaddr[j],
|
fds[*count] = anetTcp6Server(server.neterr,port,server.bindaddr[j],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user