From 9e089e7c5dbfd4ce94f59d3213fefa31a8a6228c Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 10 Jul 2013 14:34:58 +0200 Subject: [PATCH] anet.c: use SO_REUSEADDR when creating listening sockets. It used to be ok, but the socket option was removed when adding IPv6 support. --- src/anet.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/anet.c b/src/anet.c index bf8c9254..3726b9f6 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) { -- GitLab