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

Re: [Xen-devel] [PATCH 22/28] libxl: ocaml: event management



Ian Campbell writes ("Re: [PATCH 22/28] libxl: ocaml: event management"):
> On Tue, 2013-04-23 at 17:30 +0100, Rob Hoes wrote:
> > You can keep the value alive in the "main" function or toplevel.
> 
> I meant can the C bindings not take a reference to record their taking
> of the value and stashing it somewhere?

This is probably not the best way to deal with this.  It will result
in the whole libxl context never being disposed of even when it's no
longer needed.

Instead, the right approach would be to put the libxl_ctx* in some
kind of gc thunk thingy (most languages have one of these) with a
C-level freeing hook.

When the gc tells you the thing is no longer needed, you tear it all
down.

There is an awkward race here to do with events in flight, which the
libvirt guys encountered.  I'm not clearheaded enough to explain it
properly.

The void *user is just there to let your callback functions find their
context, so can point straight to your libxl context wrapper struct.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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