From: Eric Blake <eblake@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Kevin Wolf" <kwolf@redhat.com>, "Max Reitz" <mreitz@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Juan Quintela" <quintela@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/8] io: introduce a network socket listener API
Date: Thu, 10 Aug 2017 13:12:25 -0500 [thread overview]
Message-ID: <84729972-e3ab-676c-df66-4e28b754728d@redhat.com> (raw)
In-Reply-To: <20170810160451.32723-3-berrange@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3185 bytes --]
On 08/10/2017 11:04 AM, Daniel P. Berrange wrote:
> The existing QIOChannelSocket class provides the ability to
> listen on a single socket at a time. This patch introduces
> a QIONetListener class that provides a higher level API
> concept around listening for network services, allowing
> for listening on multiple sockets.
>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
> +++ b/include/io/net-listener.h
> @@ -0,0 +1,174 @@
> +/*
> + * QEMU I/O network listener
> + *
> + * Copyright (c) 2016 Red Hat, Inc.
Want to add 2017?
At least it's covered by MAINTAINERS :)
> +/**
> + * qio_net_listener_is_disconnected:
> + * @listener: the network listener object
> + *
> + * Determine if the listener is connected to any socket
> + * channels
> + *
> + * Returns: TRUE if connected, FALSE otherwise
> + */
> +gboolean qio_net_listener_is_disconnected(QIONetListener *listener);
> +
Must it return gboolean, or is bool sufficient?
TRUE if connected for a function named 'is_disconnected' sounds
backwards. Avoid the double negative, name it:
qio_net_listener_is_connected(), returning true if connected
> +++ b/io/net-listener.c
> @@ -0,0 +1,315 @@
> +/*
> + * QEMU network listener
> + *
> + * Copyright (c) 2016 Red Hat, Inc.
More 2017. Probably for the whole series :)
> +static gboolean qio_net_listener_channel_func(QIOChannel *ioc,
> + GIOCondition condition,
> + gpointer opaque)
> +{
Again, can we use bool instead of gboolean?
> +int qio_net_listener_open_sync(QIONetListener *listener,
> + SocketAddress *addr,
> + Error **errp)
> +{
> + QIODNSResolver *resolver = qio_dns_resolver_get_instance();
> + SocketAddress **resaddrs;
> + size_t nresaddrs;
> + size_t i;
> + Error *err = NULL;
> + bool success = false;
> +
> + if (qio_dns_resolver_lookup_sync(resolver,
> + addr,
> + &nresaddrs,
> + &resaddrs,
> + errp) < 0) {
> + return -1;
> + }
> +
> + for (i = 0; i < nresaddrs; i++) {
> + QIOChannelSocket *sioc = qio_channel_socket_new();
> +
> + if (qio_channel_socket_listen_sync(sioc, resaddrs[i],
> + err ? NULL : &err) == 0) {
> + success = true;
> + }
This says that as long as at least one address connected, we are
successful...
> +
> + qio_net_listener_add(listener, sioc);
...but this adds sioc as a listener regardless of whether listen_sync()
succeeded. Is that right?
> +gboolean qio_net_listener_is_disconnected(QIONetListener *listener)
> +{
> + return listener->disconnected;
Documentation says it returns true on connected, but here you are
returning true on disconnected?
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
next prev parent reply other threads:[~2017-08-10 18:12 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-10 16:04 [Qemu-devel] [PATCH 0/8] Enable full IPv4/IPv6 dual stack support Daniel P. Berrange
2017-08-10 16:04 ` [Qemu-devel] [PATCH 1/8] tests: add functional test validating ipv4/ipv6 address flag handling Daniel P. Berrange
2017-08-10 16:04 ` [Qemu-devel] [PATCH 2/8] io: introduce a network socket listener API Daniel P. Berrange
2017-08-10 18:12 ` Eric Blake [this message]
2017-08-11 9:15 ` Daniel P. Berrange
2017-08-11 10:18 ` Daniel P. Berrange
2017-08-11 12:26 ` Dr. David Alan Gilbert
2017-08-11 12:29 ` Daniel P. Berrange
2017-08-11 12:39 ` Dr. David Alan Gilbert
2017-08-11 12:48 ` Daniel P. Berrange
2017-08-10 16:04 ` [Qemu-devel] [PATCH 3/8] blockdev: convert internal NBD server to QIONetListener Daniel P. Berrange
2017-08-10 18:15 ` Eric Blake
2017-08-10 16:04 ` [Qemu-devel] [PATCH 4/8] blockdev: convert qemu-nbd " Daniel P. Berrange
2017-08-10 18:27 ` Eric Blake
2017-08-10 16:04 ` [Qemu-devel] [PATCH 5/8] migration: convert socket " Daniel P. Berrange
2017-08-10 16:04 ` [Qemu-devel] [PATCH 6/8] chardev: convert the " Daniel P. Berrange
2017-08-10 16:04 ` [Qemu-devel] [PATCH 7/8] ui: convert VNC " Daniel P. Berrange
2017-08-10 16:04 ` [Qemu-devel] [PATCH 8/8] sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr Daniel P. Berrange
2017-08-10 18:35 ` Eric Blake
2017-08-11 9:22 ` Daniel P. Berrange
2017-08-10 16:33 ` [Qemu-devel] [PATCH 0/8] Enable full IPv4/IPv6 dual stack support no-reply
2017-08-10 16:33 ` no-reply
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=84729972-e3ab-676c-df66-4e28b754728d@redhat.com \
--to=eblake@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).