[libvirt] PATCH: Clear reference after closing connection object

Daniel P. Berrange berrange at redhat.com
Tue Mar 31 12:16:31 UTC 2009


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 :|




More information about the libvir-list mailing list