-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
6 changed files
with
11 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
|
||
let close_invoked = ref 0 | ||
|
||
let close _ _ _ _ _ = | ||
let close _ _ _ _ = | ||
incr close_invoked | ||
|
||
let () = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters