On Fri, 2008-11-14 at 12:59 -0500, David Lively wrote:
On Fri, 2008-11-14 at 17:09 +0000, Daniel P. Berrange wrote:
> Or have the virConnectDomainEventRegister method take an extra parameter
> which is a callback void (*freefunc)(void*). libvirt would just invoke
> that to free the opaque data chunk.
Yeah, I like this better. The dbus(?) API allows an optional
destructor (freefunc) to be specified for callback userdata. So let's
allow it to be null (in which case we obviously don't call it at remove
time).
> I think we need a similar thing with the event loops APIs for timers
> and file handle watches, to make it easier to free the opaque data
> blob they have.
Sounds good too.
I can make the DomainEvent changes today / this weekend while working on
the Java bindings (since I need them to plug the Java leak), and submit
them on Monday (or perhaps later today, if I don't get diverted).
The attached patch implements this change (adds a "freefunc" arg to
virConnectDomainEventRegister and calls it on Deregister (or Close)).
It also modifies the event-test.c example to register a freefunc and
deregister callbacks when interrupted or terminated (to verify the
freefuncs are properly called).
Dave