[libvirt] PATCH: Clear reference after closing connection object

In the python bindings, if you call close() it will close the connection and release the handle, but it doesn't clear the python reference to the C object - self._o. So later in garbage colection __del__ runs and tries to free the already free'd object Daniel diff -r a76dc8c27d72 python/generator.py --- a/python/generator.py Tue Mar 31 12:36:02 2009 +0100 +++ b/python/generator.py Tue Mar 31 13:09:38 2009 +0100 @@ -1072,6 +1072,9 @@ def buildWrappers(): n = n + 1 classes.write(")\n"); + if name == "virConnectClose": + classes.write(" self._o = None\n") + # For functions returning object types: if ret[0] != "void": if classes_type.has_key(ret[0]): -- |: 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 :|

On Tue, Mar 31, 2009 at 01:16:31PM +0100, Daniel P. Berrange wrote:
In the python bindings, if you call close() it will close the connection and release the handle, but it doesn't clear the python reference to the C object - self._o. So later in garbage colection __del__ runs and tries to free the already free'd object
Yes, makes sense to avoid some of the errors reported previously ! ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Tue, Mar 31, 2009 at 02:47:08PM +0200, Daniel Veillard wrote:
On Tue, Mar 31, 2009 at 01:16:31PM +0100, Daniel P. Berrange wrote:
In the python bindings, if you call close() it will close the connection and release the handle, but it doesn't clear the python reference to the C object - self._o. So later in garbage colection __del__ runs and tries to free the already free'd object
Yes, makes sense to avoid some of the errors reported previously !
ACK,
Committed 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 :|
participants (2)
-
Daniel P. Berrange
-
Daniel Veillard