mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-20 11:48:28 -06:00
Fix SEGV on exit after domainEventDeregister()
When the last callback is removed using domainEventDeregister(), the events dispatcher is deregistered from the C-library, but domainEventsCallbacks is still an empty list. On shutdown __del__() deregisters the dispatacher again, which SEGVs # You need the event-loop implementation from the Python examples; # give the file a name which is importable by Python. ln examples/domain-events/events-python/event-test.py eloop.py python -c 'from eloop import * import sys def dump(*args): print " ".join(map(str, args)) virEventLoopPureStart() c = libvirt.open("xen:///") c.domainEventRegister(dump, None) c.domainEventDeregister(dump) sys.exit(0)' domainEventDeregister() needs to delete domainEventCallbacks so subsequent calls to __del__() and domainEventRegister() choose the right code paths. Setting it to None is not enough, since calling domainEventRegiser() again would trigger an TypeError. Signed-off-by: Philipp Hahn <hahn@univention.de>
This commit is contained in:
parent
2fc10e1a59
commit
eac63161cc
@ -2,7 +2,7 @@
|
|||||||
try:
|
try:
|
||||||
for cb,opaque in self.domainEventCallbacks.items():
|
for cb,opaque in self.domainEventCallbacks.items():
|
||||||
del self.domainEventCallbacks[cb]
|
del self.domainEventCallbacks[cb]
|
||||||
self.domainEventCallbacks = None
|
del self.domainEventCallbacks
|
||||||
libvirtmod.virConnectDomainEventDeregister(self._o, self)
|
libvirtmod.virConnectDomainEventDeregister(self._o, self)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
@ -17,6 +17,7 @@
|
|||||||
try:
|
try:
|
||||||
del self.domainEventCallbacks[cb]
|
del self.domainEventCallbacks[cb]
|
||||||
if len(self.domainEventCallbacks) == 0:
|
if len(self.domainEventCallbacks) == 0:
|
||||||
|
del self.domainEventCallbacks
|
||||||
ret = libvirtmod.virConnectDomainEventDeregister(self._o, self)
|
ret = libvirtmod.virConnectDomainEventDeregister(self._o, self)
|
||||||
if ret == -1: raise libvirtError ('virConnectDomainEventDeregister() failed', conn=self)
|
if ret == -1: raise libvirtError ('virConnectDomainEventDeregister() failed', conn=self)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
Loading…
Reference in New Issue
Block a user