On Mon, Nov 03, 2025 at 02:10:55PM -0600, Eric Blake wrote:
> The code had three similar repetitions of an iteration over one or all
> of nsiocs to set up a GSource, and likewise for teardown.  Since an
> upcoming patch wants to tweak whether GSource or AioContext is used,
> its better to consolidate that into one helper function for fewer
> places to edit later.
> 
> Signed-off-by: Eric Blake <[email protected]>
> ---
>  io/net-listener.c | 109 +++++++++++++++++++---------------------------
>  1 file changed, 45 insertions(+), 64 deletions(-)
> 
> diff --git a/io/net-listener.c b/io/net-listener.c
> index 15df673fb6e..e1378b9a612 100644
> --- a/io/net-listener.c
> +++ b/io/net-listener.c
> @@ -106,6 +106,45 @@ int qio_net_listener_open_sync(QIONetListener *listener,
>      }
>  }

>  void qio_net_listener_add(QIONetListener *listener,
>                            QIOChannelSocket *sioc)
> @@ -125,17 +164,7 @@ void qio_net_listener_add(QIONetListener *listener,
>      object_ref(OBJECT(sioc));
>      listener->connected = true;
> 
> -    if (listener->io_func != NULL) {
> -        trace_qio_net_listener_watch_enabled(listener, listener->io_func,
> -                                             "add");
> -        object_ref(OBJECT(listener));
> -        listener->io_source[listener->nsioc] = qio_channel_add_watch_source(
> -            QIO_CHANNEL(listener->sioc[listener->nsioc]), G_IO_IN,
> -            qio_net_listener_channel_func,
> -            listener, (GDestroyNotify)object_unref, listener->context);
> -    }
> -
> -    listener->nsioc++;
> +    qio_net_listener_watch(listener, listener->nsioc++, "add");

Nit-picking, I'd have a slight preference to keep the 'nsioc' increment
on the following line from the qio_net_listener_watch call, as I don't
like side effects in passing the function arguments.


Reviewed-by: Daniel P. Berrangé <[email protected]>

With 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 :|


Reply via email to