From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJQIx-00079v-TV for qemu-devel@nongnu.org; Tue, 10 Sep 2013 11:56:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJQIt-0002xv-DU for qemu-devel@nongnu.org; Tue, 10 Sep 2013 11:56:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJQIt-0002xq-5Q for qemu-devel@nongnu.org; Tue, 10 Sep 2013 11:56:35 -0400 Message-ID: <522F412F.9030205@redhat.com> Date: Tue, 10 Sep 2013 09:56:31 -0600 From: Eric Blake MIME-Version: 1.0 References: <1378819619-20579-1-git-send-email-ottlik@fzi.de> <1378819619-20579-2-git-send-email-ottlik@fzi.de> In-Reply-To: <1378819619-20579-2-git-send-email-ottlik@fzi.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="9oX89C7uWDMAO13IOSoGrLBmvL5iQsicw" Subject: Re: [Qemu-devel] [PATCH v3 1/5] util: add socket_set_fast_reuse function which will replace setting SO_REUSEADDR List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sebastian Ottlik Cc: Jan Kiszka , Anthony Liguori , qemu-devel@nongnu.org, Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --9oX89C7uWDMAO13IOSoGrLBmvL5iQsicw Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/10/2013 07:26 AM, Sebastian Ottlik wrote: > If a socket is closed it remains in TIME_WAIT state for some time. On o= perating > systems using BSD sockets the endpoint of the socket may not be reused = while in > this state unless SO_REUSEADDR was set on the socket. On windows on the= other > hand the default behaviour is to allow reuse (i.e. identical to SO_REUS= EADDR on > other operating systems) and setting SO_REUSEADDR on a socket allows it= to be > bound to a endpoint even if the endpoint is already used by another soc= ket > independently of the other sockets state. This can even result in undef= ined > behaviour. >=20 > Many sockets used by QEMU should not block the use of their endpoint af= ter being > closed while they are still in TIME_WAIT state. Currently QEMU sets SO_= REUSEADDR > for such sockets, which can lead to problems on Windows. This patch int= roduces > the function socket_set_fast_reuse that should be used instead of setti= ng > SO_REUSEADDR and does the right thing on all operating systems. >=20 > Signed-off-by: Sebastian Ottlik > --- > +int socket_set_fast_reuse(int fd) > +{ > + int val =3D 1, ret; > + > + ret =3D setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, > + (const char *)&val, sizeof(val)); > + > + if (ret < 0) { > + perror("setsockopt(SOL_SOCKET, SO_REUSEADDR)"); > + } This would be the first use of perror in this file; I'm not sure if that is the right function, or if there is a better thing to be using (in fact, returning -1 and letting the client decide whether to issue a warning may even be better). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --9oX89C7uWDMAO13IOSoGrLBmvL5iQsicw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSL0EvAAoJEKeha0olJ0NqFvkIAIH4BHtpftYTCGa3N91daP+l 5amxcpKGtljW+z4dXWz1bYV6/dwCuYhLLCQyBIAJQj8VGVTeZQyzxRycPrEC/5oq hE43ReTqyDGcRCDF3YocZE2NYanKnew78XsnpOpH+fwtrT+EAWYxzZRCLJDsoGgr Ct1IMh2hcLMaQYckyCDdTOGIe0brSgfVDpP0hc5jW6MKApn0RKDvRHuVb/rxxGQf 434qvFj+v/mq7pTZt3HUJj/RJ3ja1ApPThPfMLg7imlVnrLezMyH/rc5JEQatN06 YDvk6qXxp9Sav4szIw8RbzuRtWmSWv9gNC3llXb+djbBkWJP5fKOkTn4EfS+x0E= =A4CE -----END PGP SIGNATURE----- --9oX89C7uWDMAO13IOSoGrLBmvL5iQsicw--