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

Richard W.M. Jones rjones at redhat.com
Wed Mar 4 15:15:51 UTC 2020


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(-)

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
-- 
2.25.0




More information about the Libguestfs mailing list