[Libguestfs] [PATCH nbdkit] server: Only display "close: " debug message if callback is called.

Eric Blake eblake at redhat.com
Wed Mar 4 15:57:12 UTC 2020


On 3/4/20 9:15 AM, Richard W.M. Jones wrote:
> For example if .preconnect fails, it printed the debug messages:
> 
>    debug: preconnect: ...
>    debug: close: ...
> 
> This confused me into thinking that the close callback was actually
> being called without a corresponding open.  In fact it is not called
> in this case.  Suppress the debug message unless the callback is
> actually being called.
> ---
>   server/backend.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Makes sense, but .finalize should get the same treatment since it 
likewise gets skipped when .prepare fails.

> 
> diff --git a/server/backend.c b/server/backend.c
> index 51b56a48..108f4a25 100644
> --- a/server/backend.c
> +++ b/server/backend.c
> @@ -241,10 +241,10 @@ backend_close (struct backend *b)
>     struct handle *h = get_handle (conn, b->i);
>   
>     /* outer-to-inner order, opposite .open */
> -  controlpath_debug ("%s: close", b->name);
>   
>     if (h->handle) {
>       assert (h->state & HANDLE_OPEN);
> +    controlpath_debug ("%s: close", b->name);
>       b->close (b, h->handle);
>     }
>     else
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list