Make an EADDRINUSE on server bind fatal.

This is important because if we try to rebind after a migration and
someone else is in the way, any clients trying to reconnect to us will
instead be connecting to the squatter.
This commit is contained in:
Alex Young
2012-07-16 12:34:39 +01:00
parent 2e20e7197a
commit 1caa3d4e27
4 changed files with 18 additions and 12 deletions

View File

@@ -232,13 +232,21 @@ void serve_bind( struct server * serve )
* Any of these other than EACCES,
* EADDRINUSE or EADDRNOTAVAIL signify
* that there's a logic error somewhere.
*
* EADDRINUSE is fatal: if there's
* something already where we want to be
* listening, we have no guarantees that
* any clients will cope with it.
*/
case EACCES:
case EADDRINUSE:
case EADDRNOTAVAIL:
debug("retrying");
sleep(1);
continue;
case EADDRINUSE:
fatal( "%s port %d in use, giving up.",
s_address,
ntohs(serve->bind_to.v4.sin_port));
default:
fatal( "Giving up" );
}