From: "Daniel P. Berrange" <berrange@redhat.com>
To: Knut Omang <knut.omang@oracle.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v5 2/4] sockets: factor out create_fast_reuse_socket
Date: Tue, 25 Jul 2017 10:38:24 +0100 [thread overview]
Message-ID: <20170725093824.GJ26394@redhat.com> (raw)
In-Reply-To: <ee5cd7796873b061804bf6f8546759109473000b.1500709594.git-series.knut.omang@oracle.com>
On Sat, Jul 22, 2017 at 09:49:31AM +0200, Knut Omang wrote:
> First refactoring step to prepare for fixing the problem
> exposed with the test-listen test in the previous commit
>
> Signed-off-by: Knut Omang <knut.omang@oracle.com>
> ---
> util/qemu-sockets.c | 24 +++++++++++++++++-------
> 1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> index 1358c81..578f25b 100644
> --- a/util/qemu-sockets.c
> +++ b/util/qemu-sockets.c
> @@ -149,6 +149,20 @@ int inet_ai_family_from_address(InetSocketAddress *addr,
> return PF_UNSPEC;
> }
>
> +static int create_fast_reuse_socket(struct addrinfo *e, Error **errp)
> +{
> + int slisten = qemu_socket(e->ai_family, e->ai_socktype, e->ai_protocol);
> + if (slisten < 0) {
> + if (!e->ai_next) {
> + error_setg_errno(errp, errno, "Failed to create socket");
> + }
> + return -1;
> + }
> +
> + socket_set_fast_reuse(slisten);
> + return slisten;
> +}
As mentioned in the previous review, I don't think we should have
methods like this which sometimes report an error on failure, and
sometimes don't report an error. It makes it hard to review the
callers for correctness of error handling.
> +
> static int inet_listen_saddr(InetSocketAddress *saddr,
> int port_offset,
> bool update_addr,
> @@ -210,21 +224,17 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
> return -1;
> }
>
> - /* create socket + bind */
> + /* create socket + bind/listen */
> for (e = res; e != NULL; e = e->ai_next) {
> getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen,
> uaddr,INET6_ADDRSTRLEN,uport,32,
> NI_NUMERICHOST | NI_NUMERICSERV);
> - slisten = qemu_socket(e->ai_family, e->ai_socktype, e->ai_protocol);
> +
> + slisten = create_fast_reuse_socket(e, &err);
> if (slisten < 0) {
> - if (!e->ai_next) {
> - error_setg_errno(errp, errno, "Failed to create socket");
> - }
So please leave this here.
> continue;
> }
>
> - socket_set_fast_reuse(slisten);
> -
> port_min = inet_getport(e);
> port_max = saddr->has_to ? saddr->to + port_offset : port_min;
> for (p = port_min; p <= port_max; p++) {
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2017-07-25 9:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-22 7:49 [Qemu-devel] [PATCH v5 0/4] Unit test+fix for problem with QEMU handling of multiple bind()s to the same port Knut Omang
2017-07-22 7:49 ` [Qemu-devel] [PATCH v5 1/4] tests: Add test-listen - a stress test for QEMU socket listen Knut Omang
2017-07-22 7:49 ` [Qemu-devel] [PATCH v5 2/4] sockets: factor out create_fast_reuse_socket Knut Omang
2017-07-25 9:38 ` Daniel P. Berrange [this message]
2017-07-29 20:24 ` Knut Omang
2017-07-22 7:49 ` [Qemu-devel] [PATCH v5 3/4] sockets: factor out a new try_bind() function Knut Omang
2017-07-25 9:39 ` Daniel P. Berrange
2017-07-22 7:49 ` [Qemu-devel] [PATCH v5 4/4] sockets: Handle race condition between binds to the same port Knut Omang
2017-07-25 9:54 ` Daniel P. Berrange
2017-07-29 20:24 ` Knut Omang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170725093824.GJ26394@redhat.com \
--to=berrange@redhat.com \
--cc=knut.omang@oracle.com \
--cc=kraxel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.