[Libguestfs] [libnbd] More thoughts on callbacks and more
Eric Blake
eblake at redhat.com
Mon Jul 22 14:33:40 UTC 2019
On 7/22/19 9:25 AM, Richard W.M. Jones wrote:
> This has an annoying subtlety around the fact that we can pass a
> single user_data and multiple closures in one function call.
>
> The LIBNBD_CALLBACK_FREE function would be called several times with
> the same user_data in this case, which means the callback must do some
> kind of reference counting before the user_data can be freed.
>
> I propose that we split up Closure so it describes a single closure,
> although that does mean that separate user_data must be passed with
> each function pointer (which may not be a bad thing).
Indeed, and it is a bit more API churn (nbd_aio_pread_structured_allback
and nbd_aio_block_status_callback would now take two void* user_data
parameters, which means they must have different parameter names: maybe
extent_user_data vs. callback_user_data), but it makes sense. But it
also simplifies 'Closure' in the generator, as you no longer have an
array of callback functions that share a common data.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190722/d3275e04/attachment.sig>
More information about the Libguestfs
mailing list