[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 1/1] tools/ocaml: Re-introduce Xenctrl.with_intf wrapper



Christian Lindig writes ("[Xen-devel] [PATCH 1/1] tools/ocaml: Re-introduce 
Xenctrl.with_intf wrapper"):
> Commit 81946a73dc975a7dafe9017a8e61d1e64fdbedbf removed
> Xenctrl.with_intf based on its undesirable behaviour of opening and
> closing a Xenctrl connection with every invocation. This commit
> re-introduces with_intf but with an updated behaviour: it maintains a
> global Xenctrl connection which is opened upon first usage and kept
> open. This handle can be obtained by clients using new functions
> get_handle() and close_handle().
...
> +let handle = ref None
> +
> +let get_handle () = !handle
> +
> +let close_handle () =
> +     match !handle with
> +     | Some h -> interface_close h
> +     | None -> ()

The semantics of close_handle are strange.  After it is used, handle
remains Some but is broken.

I think it would be better to have close_handle set handle to None,
and write in the docs that it is forbidden to call close_handle within
with_intf.  (Would it be possible to detect such a mistake?)

For that matter, why is close_handle needed at all ?

Regards,
Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.