mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 07:05:28 +00:00
Clean timer in virObjectEventStateFlush
If the last event callback is unregistered while the event loop is dispatching, it is only marked as deleted, but not removed. The number of callbacks is more than zero in that case, so the timer is not removed. Because it can be removed in this function now (but also accessed afterwards so that we set 'isDispatching = false' and have it locked), we need to temporarily increase the reference counter of the state for the duration of this function. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
6fecf9523a
commit
44bf83e313
@ -807,6 +807,9 @@ virObjectEventStateFlush(virObjectEventStatePtr state)
|
||||
{
|
||||
virObjectEventQueue tempQueue;
|
||||
|
||||
/* We need to lock as well as ref due to the fact that we might
|
||||
* unref the state we're working on in this very function */
|
||||
virObjectRef(state);
|
||||
virObjectLock(state);
|
||||
state->isDispatching = true;
|
||||
|
||||
@ -826,8 +829,13 @@ virObjectEventStateFlush(virObjectEventStatePtr state)
|
||||
/* Purge any deleted callbacks */
|
||||
virObjectEventCallbackListPurgeMarked(state->callbacks);
|
||||
|
||||
/* If we purged all callbacks, we need to remove the timeout as
|
||||
* well like virObjectEventStateDeregisterID() would do. */
|
||||
virObjectEventStateCleanupTimer(state, true);
|
||||
|
||||
state->isDispatching = false;
|
||||
virObjectUnlock(state);
|
||||
virObjectUnref(state);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user