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
This commit is contained in:
Michael Adam 2009-12-08 01:21:35 +01:00
parent 5bba62bcde
commit d522221668

View File

@ -194,6 +194,9 @@ int listen_sock (uint16_t port, socklen_t * addrlen)
if (listenfd == -1) if (listenfd == -1)
continue; continue;
setsockopt (listenfd, SOL_SOCKET, SO_REUSEADDR, &on,
sizeof (on));
if (bind (listenfd, rp->ai_addr, rp->ai_addrlen) == 0) if (bind (listenfd, rp->ai_addr, rp->ai_addrlen) == 0)
break; /* success */ break; /* success */
@ -210,8 +213,6 @@ int listen_sock (uint16_t port, socklen_t * addrlen)
return -1; return -1;
} }
setsockopt (listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on));
if (listen (listenfd, MAXLISTEN) < 0) { if (listen (listenfd, MAXLISTEN) < 0) {
log_message (LOG_ERR, log_message (LOG_ERR,
"Unable to start listening socket because of %s", "Unable to start listening socket because of %s",