summaryrefslogtreecommitdiffhomepage
path: root/src/sock.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2009-12-08 01:21:35 +0100
committerMichael Adam <obnox@samba.org>2009-12-08 01:24:31 +0100
commitd522221668e4ab7bb925b01c276ac462c899bcbf (patch)
treebb28d9dec0c1d887ef467e00188392af190d3039 /src/sock.c
parent5bba62bcde2f6a7cf35e566ab673b85aef2bdae8 (diff)
Fix restarting of tinyproxy: call setsockopt with REUSEADDR _before_ calling bind
Somehow this got moved too far down in the ipv6 changes. Thanks to Mathew Mrosko for helping me debugging this. Michael
Diffstat (limited to 'src/sock.c')
-rw-r--r--src/sock.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/sock.c b/src/sock.c
index be50376..bf32c78 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -163,7 +163,7 @@ int socket_blocking (int sock)
* Start listening to a socket. Create a socket with the selected port.
* The size of the socket address will be returned to the caller through
* the pointer, while the socket is returned as a default return.
- * - rjkaes
+ * - rjkaes
*/
int listen_sock (uint16_t port, socklen_t * addrlen)
{
@@ -194,6 +194,9 @@ int listen_sock (uint16_t port, socklen_t * addrlen)
if (listenfd == -1)
continue;
+ setsockopt (listenfd, SOL_SOCKET, SO_REUSEADDR, &on,
+ sizeof (on));
+
if (bind (listenfd, rp->ai_addr, rp->ai_addrlen) == 0)
break; /* success */
@@ -210,8 +213,6 @@ int listen_sock (uint16_t port, socklen_t * addrlen)
return -1;
}
- setsockopt (listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on));
-
if (listen (listenfd, MAXLISTEN) < 0) {
log_message (LOG_ERR,
"Unable to start listening socket because of %s",