summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-07-10 14:34:58 +0200
committerantirez <antirez@gmail.com>2013-07-10 14:34:58 +0200
commitd83dca4c79850cd8a271f534fa651b0c46666c6a (patch)
tree12d49ed5d1acd76393ebe148889a17d3cd1320b9
parentd1cbad6d1404c62d90921280f5d180bb5d67f097 (diff)
downloadredis-d83dca4c79850cd8a271f534fa651b0c46666c6a.tar.gz
anet.c: use SO_REUSEADDR when creating listening sockets.
It used to be ok, but the socket option was removed when adding IPv6 support.
-rw-r--r--src/anet.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/anet.c b/src/anet.c
index bf8c92549..3726b9f67 100644
--- a/src/anet.c
+++ b/src/anet.c
@@ -392,11 +392,9 @@ 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 == AF_INET6 && anetV6Only(err,s) == ANET_ERR)
- goto error; /* could continue here? */
-
- if (anetListen(err,s,p->ai_addr,p->ai_addrlen) == ANET_ERR)
- goto error; /* could continue here? */
+ if (af == AF_INET6 && anetV6Only(err,s) == ANET_ERR) goto error;
+ if (anetSetReuseAddr(err,s) == ANET_ERR) goto error;
+ if (anetListen(err,s,p->ai_addr,p->ai_addrlen) == ANET_ERR) goto error;
goto end;
}
if (p == NULL) {