On 8/12/19 11:08 AM, Richard W.M. Jones wrote:
The freeing feature can now be done by associating a free callback with a closure's user_data, so having the valid_flag is no longer necessary and it can be completely removed.
This mostly reverts commit 2d9b98e96772e282d51dafac07f16387dadc8afa.
Aha - the end goal is to get rid of valid_flag. But still, we might be able to do that by instead having C expand Closure into a 3-tuple (callback, free_cb, user_data) where we call callback(user_data, args) as needed and then free_cb(user_data) when done, rather than having to add a list of free callback registrations. Definitely an API/ABI change (the fio code using the existing interface will need tweaking), but seems like a worthwhile goal, even if we change our minds about how best to get to this point. I'll have to play more with the ideas of making the generator smarter about using underlying nbd_aio_pread_callback even for the public Python/OCaml nbd.nbd_aio_pread as a way to create a C structure that can call free_cb(wrapper) to clean up the lifetime of both the buffer and any language callback reference. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org