mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
ocaml: Fix guestfs_065_implicit_close.ml for OCaml 5
Link: https://discuss.ocaml.org/t/ocaml-5-forcing-objects-to-be-collected-and-finalized/12492/3 Thanks: Josh Berdine Thanks: Vincent Laviron
This commit is contained in:
@@ -16,10 +16,12 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*)
|
||||
|
||||
let close_invoked = ref 0
|
||||
let [@inline never][@local never] run () =
|
||||
let close_invoked = ref 0 in
|
||||
|
||||
let close _ _ _ _ =
|
||||
incr close_invoked
|
||||
in
|
||||
|
||||
let () =
|
||||
let g = new Guestfs.guestfs () in
|
||||
@@ -28,10 +30,13 @@ let () =
|
||||
(* Allow the 'g' handle to go out of scope here, to ensure there is no
|
||||
* reference held on the stack.
|
||||
*)
|
||||
in
|
||||
|
||||
(* This should cause the GC to close the handle. *)
|
||||
let () = Gc.full_major ()
|
||||
Gc.full_major ();
|
||||
|
||||
let () = assert (!close_invoked = 1)
|
||||
assert (!close_invoked = 1);
|
||||
|
||||
let () = Gc.compact ()
|
||||
Gc.compact ()
|
||||
|
||||
let () = run ()
|
||||
|
||||
Reference in New Issue
Block a user