From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJQu0-0000x5-Ol for qemu-devel@nongnu.org; Tue, 10 Sep 2013 12:35:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJQtv-0006Nr-JR for qemu-devel@nongnu.org; Tue, 10 Sep 2013 12:34:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18940) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJQtv-0006Nl-Be for qemu-devel@nongnu.org; Tue, 10 Sep 2013 12:34:51 -0400 Message-ID: <522F4A26.8080805@redhat.com> Date: Tue, 10 Sep 2013 10:34:46 -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> <522F412F.9030205@redhat.com> <522F4775.1070606@fzi.de> In-Reply-To: <522F4775.1070606@fzi.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AAoFTwUkP2eft76BVwhNNTtAjTKEWE7pG" 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) --AAoFTwUkP2eft76BVwhNNTtAjTKEWE7pG Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/10/2013 10:23 AM, Sebastian Ottlik wrote: >>> + 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 th= at >> 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). >> > When I started writing the patch I was going to return the error and la= t > the client handle the issue. But the code in net/socket.c then becomes:= >=20 > ret =3D socket_set_fast_reuse(fd); > if (ret < 0) { > perror("setsockopt(SOL_SOCKET, SO_REUSEADDR)"); > closesocket(fd); > return -1; > } >=20 > Which looked unclean to me, as the code implies assumptions about the > implementation of socket_set_fast_reuse. One could also call > perror("socket_set_fast_reuse()") but this would break the convention i= n > the surrounding code of passing for the function that failed to perror.= Maybe a compromise? Add a 'bool silent' flag to socket_set_fast_reuse, and only issue perror() if the flag is false. Existing callers that don't care about failure (if we get fast reuse, great; if not, no huge loss) pass false, existing callers that did their own error reporting pass true to take advantage of the perror() on failure, and then you aren't changing semantics at call sites. But I'm just making this observation from the side; you might want to get an opinion from an actual maintainer of this area of code on which approach is best. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --AAoFTwUkP2eft76BVwhNNTtAjTKEWE7pG 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/ iQEcBAEBCAAGBQJSL0omAAoJEKeha0olJ0NqqLkH/3tDrCI/J2BoFnWkLHAEwbM/ 0Up7RFtcgV4aJWjIpJcMfKR1Q2c0lSzFSCOY9KjDARZVhYbEg1LtsCRR/pNBwWYg lM39KVxERu78GV+fwWJk3IFrWy5YbVdG2XCNO/dcg7TBWLPlAVvDMwHfxS4wGump uujA2EqHkZV3570xvQLR0TkBY9aM3gusig81DLg5GiV5mTbaEvsX1wIf89ctKvJm lp8RmyQovYdr9Qk4MULhMAgoLjU2PAkdEwitsNPhow4v5/N2ZIKGYaipjfQRlcWo LsZEQBfyq0Lp+POx/qmyN+c43f7DnN5gBugwtVIdMtkVnU+pbv4cVQPn88jyTgU= =8p69 -----END PGP SIGNATURE----- --AAoFTwUkP2eft76BVwhNNTtAjTKEWE7pG--