1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-08-03 08:21:58 +03:00

libvirtaio: do not double-add callbacks

This was a harmless bug, without any impact, but it is wrong to manage
the collection of callbacks from it's members.

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
This commit is contained in:
Wojtek Porczyk
2017-09-14 02:24:29 +02:00
committed by Daniel P. Berrange
parent a5cc6da2c8
commit cc82a94528

View File

@ -63,11 +63,6 @@ class Callback(object):
self.cb = cb
self.opaque = opaque
assert self.iden not in self.impl.callbacks, \
'found {} callback: {!r}'.format(
self.iden, self.impl.callbacks[self.iden])
self.impl.callbacks[self.iden] = self
def __repr__(self):
return '<{} iden={}>'.format(self.__class__.__name__, self.iden)
@ -324,6 +319,8 @@ class virEventAsyncIOImpl(object):
'''
callback = FDCallback(self, cb, opaque,
descriptor=self.descriptors[fd], event=event)
assert callback.iden not in self.callbacks
self.log.debug('add_handle(fd=%d, event=%d, cb=..., opaque=...) = %d',
fd, event, callback.iden)
self.callbacks[callback.iden] = callback
@ -376,6 +373,8 @@ class virEventAsyncIOImpl(object):
https://libvirt.org/html/libvirt-libvirt-event.html#virEventAddTimeoutFunc
'''
callback = TimeoutCallback(self, cb, opaque)
assert callback.iden not in self.callbacks
self.log.debug('add_timeout(timeout=%d, cb=..., opaque=...) = %d',
timeout, callback.iden)
self.callbacks[callback.iden] = callback