CA-66512: Properly set SO_REUSEADDR when (re)starting HIMN XenAPI server
CA-66512: Properly set SO_REUSEADDR when (re)starting HIMN XenAPI server

When rebooting the VM soon after the VM talked to xapi using wget, the
HIMN XenAPI server stopped working. The reason was as follows.

The wget command sets up a TCP connection with xapi, which is closed after
the command is done. However, the TCP socket on the xapi side does not go
away immediately, but stays in a state called TIME_WAIT for a while (a
minute or so). When the VM starts up again, xapi opens a new HIMN socket,
which fails because there was already a socket on the same address/port.
Setting the SO_REUSEADDR option on the socket gets rid of the problem,
because it allows new sockets for the same (local) address/port. This
option was actually set in the code, but apparently too late in the sequence
(after the "bind" operation).

Signed-off-by: Rob Hoes <8783b3376fb07d39edffc8d7da68a6de3874a7e6@citrix.com>

cheng--zhang/xen-api,rafalmiel/xen-api,koushikcgit/xen-api,Frezzle/xen-api,rafalmiel/xen-api,cheng-z/xen-api,djs55/xen-api,jjd27/xen-api,robertbreker/xen-api,ravippandey/xen-api,cheng-z/xen-api,thomassa/xen-api,srowe/xen-api,rafalmiel/xen-api,srowe/xen-api,thomassa/xen-api,anoobs/xen-api,agimofcarmen/xen-api,huizh/xen-api,vasilenkomike/xen-api,koushikcgit/xen-api,thomassa/xen-api,vasilenkomike/xen-api,koushikcgit/xen-api,jjd27/xen-api,guard163/xen-api,vasilenkomike/xen-api,Frezzle/xen-api,jjd27/xen-api,euanh/xen-api,robertbreker/xen-api,vasilenkomike/xen-api,huizh/xen-api,cheng--zhang/xen-api,guard163/xen-api,vasilenkomike/xen-api,djs55/xen-api,cheng-z/xen-api,koushikcgit/xen-api,simonjbeaumont/xen-api,anoobs/xen-api,huizh/xen-api,ravippandey/xen-api,rafalmiel/xen-api,euanh/xen-api,salvocambria/xen-api,rafalmiel/xen-api,salvocambria/xen-api,agimofcarmen/xen-api,guard163/xen-api,Frezzle/xen-api,cheng--zhang/xen-api,srowe/xen-api,robertbreker/xen-api,djs55/xen-api,simonjbeaumont/xen-api,huizh/xen-api,thomassa/xen-api,cheng--zhang/xen-api,huizh/xen-api,agimofcarmen/xen-api,cheng--zhang/xen-api,euanh/xen-api,koushikcgit/xen-api,agimofcarmen/xen-api,agimofcarmen/xen-api,salvocambria/xen-api,euanh/xen-api,cheng--zhang/xen-api,salvocambria/xen-api,simonjbeaumont/xen-api,djs55/xen-api,anoobs/xen-api,euanh/xen-api,anoobs/xen-api,srowe/xen-api,jjd27/xen-api,srowe/xen-api,huizh/xen-api,thomassa/xen-api,cheng-z/xen-api,guard163/xen-api,guard163/xen-api,cheng-z/xen-api,robertbreker/xen-api,anoobs/xen-api,rafalmiel/xen-api,cheng-z/xen-api,jjd27/xen-api,Frezzle/xen-api,Frezzle/xen-api,ravippandey/xen-api,djs55/xen-api,cheng-z/xen-api,agimofcarmen/xen-api,thomassa/xen-api,simonjbeaumont/xen-api,robertbreker/xen-api,cheng--zhang/xen-api,ravippandey/xen-api,anoobs/xen-api,simonjbeaumont/xen-api,robertbreker/xen-api,guard163/xen-api,vasilenkomike/xen-api,ravippandey/xen-api,djs55/xen-api,jjd27/xen-api,ravippandey/xen-api,koushikcgit/xen-api,salvocambria/xen-api,simonjbeaumont/xen-api,salvocambria/xen-api,euanh/xen-api