[Libguestfs] [PATCH libnbd 0/2] Use free callback to dereference NBD.Buffer.

Richard W.M. Jones rjones at redhat.com
Wed Aug 14 19:31:46 UTC 2019


In this patch series we use the newly introduced free callback
on the completion function to dererence the OCaml NBD.Buffer.
I will make the same kind of change for Python later in a
separate series.

The completion function is always called at the C level, even
if the OCaml program didn't use the optional argument.  That's
because the free callback doesn't run otherwise.

There is a case for having the free callback run even if there is no
registered callback:

  nbd_aio_pread (nbd, buf, sizeof buf, 0,
                 (nbd_completion_callback) { .callback = NULL,
                                             .free = completion_free },
                 0);

but the semantics of that are a bit weird.  Why would you need to
"free" a callback which doesn't exist?  Would it be correct for the
library to free the callback immediately, rather than after the
theoretical completion callback would have run?

Rich.





More information about the Libguestfs mailing list