On Thu, May 06, 2021 at 08:59:39PM -0500, Eric Blake wrote:
The existing .unload callback is currently called inner-to-outer,
which is not suitable for use in late cleanups where a filter wants to
make one final call into the underlying plugin. We were careful to
state that unload does not have a specific ordering, but switching
that ordering may not be helpful. Late cleanup may also want one
final chance to open a context into the plugin, which implies one
final access to the backend pointer from filters (in contrast to
.unload taking no parameters).
So, I found it easier to introduce a new .cleanup callback,
specifically stated to be the counterpart of .after_fork. This leaves
.load/.unload as a pair for handling things at the dlopen barrier
(affecting only the local filter or plugin, but no interaction with
other modules), and .after_fork/.cleanup for handling things related
to the first and last points at which it is safe to interact with the
underlying plugin. The new callback has no return value, as by the
time we are cleaning up, any failures are not going to change the fact
we are shutting down anyway.
---
docs/nbdkit-filter.pod | 22 +++++++++++++++++++---
docs/nbdkit-plugin.pod | 33 ++++++++++++++++++++++++++++++---
include/nbdkit-filter.h | 1 +
include/nbdkit-plugin.h | 4 +++-
server/internal.h | 2 ++
server/filters.c | 13 +++++++++++++
server/main.c | 1 +
server/plugins.c | 13 +++++++++++++
tests/test-layers-filter.c | 8 ++++++++
tests/test-layers-plugin.c | 9 ++++++++-
tests/test-layers.c | 12 ++++++++++++
11 files changed, 110 insertions(+), 8 deletions(-)
Yes this one is fine - it could be pushed immediately.
The difference between plugin.cleanup and plugin.unload
is quite subtle :-)
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v