Files
libguestfs/ocaml
Richard W.M. Jones 8bbc5e73cb ocaml: Allow Guestfs.t handle to be garbage collected.
** NB: This is an API break for OCaml programs using Guestfs.event_callback. **

Because of the way I implemented Guestfs.event_callback which had the
Guestfs.t handle as the first parameter, we had to store the (OCaml)
Guestfs.t handle in the C handle's private data area.  To do that, we
had to create a global root pointing to the handle.

This of course meant that the handle could not be garbage collected
(thanks Roman Kagan for spotting this).

This changes the API of Guestfs.event_callback so that a handle is no
longer passed.  The OCaml handle can now be garbage collected again.

For programs that need the Guestfs.t handle in the callback function
(which turns out to be *none* of the OCaml programs we have written),
you can do:

  g#set_event_callback (callback_fn g) [Guestfs.EVENT_FOO];

In this case, since the closure passed to Guestfs.set_event_callback
is still registered as a global root, that will capture a reference to
the handle, so the handle won't be able to be garbage collected until
you delete the callback.
2015-10-06 22:28:27 +01:00
..
2015-01-17 09:08:15 +00:00
2011-07-17 11:23:47 +01:00
2015-01-17 09:08:15 +00:00