summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-09-09 14:59:48 +0200
committerantirez <antirez@gmail.com>2016-09-12 10:56:25 +0200
commitc01abcdebf4fa2b1cd3d3a89049651d528ed5656 (patch)
treee8d526197500c76c9d7f7b7b95a246aaab26ba41
parenta6d0698b22e453221403e6aa5733c23897c20c69 (diff)
downloadredis-c01abcdebf4fa2b1cd3d3a89049651d528ed5656.tar.gz
fix the fix for the TCP binding.
This commit attempts to fix a problem with PR #3467.
-rw-r--r--src/server.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/server.c b/src/server.c
index 3792b5999..408d03fba 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1784,19 +1784,24 @@ int listenToPort(int port, int *fds, int *count) {
if (fds[*count] != ANET_ERR) {
anetNonBlock(NULL,fds[*count]);
(*count)++;
- } else if (errno == EAFNOSUPPORT)
+ } else if (errno == EAFNOSUPPORT) {
unsupported++;
+ serverLog(LL_WARNING,"Not listening to IPv6: unsupproted");
+ }
- /* 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)++;
- } else if (errno == EAFNOSUPPORT)
- unsupported++;
+ if (*count == 1 || unsupported) {
+ /* 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)++;
+ } else if (errno == EAFNOSUPPORT) {
+ unsupported++;
+ serverLog(LL_WARNING,"Not listening to IPv4: unsupproted");
+ }
+ }
/* Exit the loop if we were able to bind * on IPv4 and IPv6,
- * or if one is unsupported by th OS.
* otherwise fds[*count] will be ANET_ERR and we'll print an
* error and return to the caller with an error. */
if (*count + unsupported == 2) break;