On Fri, Jan 16, 2009 at 01:35:37PM +0100, Daniel Veillard wrote: > On Thu, Jan 15, 2009 at 05:18:40PM +0000, Richard W.M. Jones wrote: > > On Tue, Jan 13, 2009 at 05:43:08PM +0000, Daniel P. Berrange wrote: > > > With the domain events code, the callbacks triggered upon events get given > > > a virDomainPtr object instance. In many cases it'd be desirable to grab > > > this object and keep it in your app code. Unfortunately it is free'd the > > > moment the callback finishes executing. > > > > > > When allowing multiple threads to access a single virConnectPtr object > > > it is neccessary to ensure no thread releases it (virConnectCLose) while > > > another thread is still using it. > > > > > > The way to address both of these problems is to allow an application to > > > take an explicit reference on the object in question. So this patch > > > exposes methods to allow an app to increment the ref count on all our > > > public objects. To release the ref count, the existing virConectClose/ > > > virDOmainFree, etc methods suffice > > > > > > include/libvirt/libvirt.h | 6 + > > > include/libvirt/libvirt.h.in | 6 + > > > src/libvirt.c | 183 +++++++++++++++++++++++++++++++++++++++++++ > > > src/libvirt_public.syms | 12 ++ > > > 4 files changed, 206 insertions(+), 1 deletion(-) > > > > Poor man's garbage collection ... +1. > > Yeah it's unfortunate we have to add this at the API level, but > unfortunately there is no way around. > I wonder if we could resurrect some of the deprecated fields of > error structure now, seems to me that would be possible now. Unfortunately this isn't sufficient to make use of the dom/net fields practical. If we hold onto a reference when setting the error object, then we have a possible indefinite memory leak, unless the app calling libvirt always runs virResetLastError() after every API call. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list