diff options
author | antirez <antirez@gmail.com> | 2013-08-22 13:02:59 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-08-22 13:03:07 +0200 |
commit | bd6327855b3a68b9a1de8203fce9f7a8b427d914 (patch) | |
tree | d7567b1b35bcdbebfd180f8edc932fc7d9fcb215 | |
parent | 2c94d80f58f2794ae3028a48ebdcc92e25b83e03 (diff) | |
download | redis-bd6327855b3a68b9a1de8203fce9f7a8b427d914.tar.gz |
Print error message when can't bind * on any address.
-rw-r--r-- | src/redis.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/redis.c b/src/redis.c index 2a2ce83c0..b87116d21 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1468,8 +1468,7 @@ void initServer() { for (j = 0; j < server.bindaddr_count || j == 0; j++) { if (server.bindaddr[j] == NULL) { /* 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.bindaddr_count == 0. */ server.ipfd[server.ipfd_count] = anetTcp6Server(server.neterr,server.port,NULL); if (server.ipfd[server.ipfd_count] != ANET_ERR) @@ -1478,7 +1477,10 @@ void initServer() { anetTcpServer(server.neterr,server.port,NULL); if(server.ipfd[server.ipfd_count] != ANET_ERR) server.ipfd_count++; - break; + /* Exit the loop if we were able to bind * on IPv4 or IPv6, + * otherwise server.ipfd[server.ipfd_count] will be ANET_ERR + * and we'll print an error and exit. */ + if (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]); |