I have added an autoconf check for the SO_REUSEADDR bug in the base
library,
and modified the networking code to use the simple workaround of not using
SO_REUSEADDR on systems where it is broken (windoze, some FreeBSDs, and
some
versions of Solaris AFAIK).
Explanation of the bug ... the SO_REUSEADDR option is set on a network
socket
to say that, if the socket is in a TIME_WAIT state (ie it has recently been
closed, but the handshake for the close with the other end of the socket
has
not been completed) then the socket address/port may be re-used
immediately.
This permits a service to be restarted on the same address/port without
having
to wait for the (typically 1 to 4 minute) timeout.
On some systems (windoze, some versions of FreeBSD, some of Solaris, and
perhaps
a few others), using SO_REUSEADDR actually permits the address/port to
be re-used
*no-matter-what-state-it's-in*.
This has two effects -
1. a security issue - since other processes can bind to the same address
as your process and steal packets.
2. more importantly for us, we can't attempt to bind to an address/port in
order to find out if there is already a process using it - our bind attempt
will succeed when it really shouldn't. This means that you can start
multiple
copies of servers using the same name ... since the nameserver process will
always think that the old server has died.
Not using SO_REUSEADDR will leave most networking unaffected, but if a
gdomap process is killed, it will not be able to restart until the system
timeout has expired.