anet.c: use SO_REUSEADDR when creating listening sockets.

It used to be ok, but the socket option was removed when adding IPv6
support.
This commit is contained in:
antirez 2013-07-10 14:34:58 +02:00
parent d1cbad6d14
commit d83dca4c79

View File

@ -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) if ((s = socket(p->ai_family,p->ai_socktype,p->ai_protocol)) == -1)
continue; continue;
if (af == AF_INET6 && anetV6Only(err,s) == ANET_ERR) if (af == AF_INET6 && anetV6Only(err,s) == ANET_ERR) goto error;
goto error; /* could continue here? */ if (anetSetReuseAddr(err,s) == ANET_ERR) goto error;
if (anetListen(err,s,p->ai_addr,p->ai_addrlen) == ANET_ERR) goto error;
if (anetListen(err,s,p->ai_addr,p->ai_addrlen) == ANET_ERR)
goto error; /* could continue here? */
goto end; goto end;
} }
if (p == NULL) { if (p == NULL) {