]> xenbits.xensource.com Git - libvirt.git/commit
Remove all object hashtable caches from virConnectPtr
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 29 Oct 2010 11:43:34 +0000 (12:43 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 21 Feb 2011 11:50:46 +0000 (11:50 +0000)
commit2ff4c13754311cc3f888ddf4204ea53d3102e3de
treef2f375cda1b23b90060b611192026371d2ee9251
parent912d170f87b3d147bfde987249a727f7a7c7f1d7
Remove all object hashtable caches from virConnectPtr

The virConnectPtr struct will cache instances of all other
objects. APIs like virDomainLookupByUUID will return a
cached object, so if you do virDomainLookupByUUID twice in
a row, you'll get the same exact virDomainPtr instance.

This does not have any performance benefit, since the actual
logic in virDomainLookupByUUID (and other APIs returning
virDomainPtr, etc instances) is not short-circuited. All
it does is to ensure there is only one single virDomainPtr
in existance for any given UUID.

The caching has a number of downsides though, all relating
to stale data. If APIs aren't careful to always overwrite
the 'id' field in virDomainPtr it may become out of data.
Likewise for the name field, if a guest is renamed, or if
a guest is deleted, and then a new one created with the
same UUID but different name.

This has been an ongoing, endless source of bugs for all
applications using libvirt from languages with garbage
collection, causing them to get virDomainPtr instances
from long ago with stale data.

The caching is also a waste of memory resources, since
both applications, and language bindings often maintain
their own hashtable caches of object instances.

This patch removes all the hash table caching, so all
APIs return brand new virDomainPtr (etc) object instances.

* src/datatypes.h: Delete all hash tables.
* src/datatypes.c: Remove all object caching code
src/datatypes.c
src/datatypes.h