mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
ch: Fix refcounting in virCHEventHandlerLoop() and virCHStartEventHandler()
When event handler thread is created inside of virCHStartEventHandler() the monitor object is refed because the thread (virCHEventHandlerLoop()) that's created in the very next step uses it. But right after that, the monitor object is unrefed, which is wrong because it takes away the reference which was handed over to the thread. The monitor must be unrefed inside the thread, when no longer needed. And while at it, move the unref call of the domain object after the debug print which obviously accesses the domain definition. Signed-off-by: Kirill Shchetiniuk <kshcheti@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
committed by
Michal Privoznik
parent
1db1244752
commit
fc201e0fcc
+2
-2
@@ -287,8 +287,9 @@ virCHEventHandlerLoop(void *data)
|
||||
}
|
||||
|
||||
g_clear_pointer(&mon->event_buffer.buffer, g_free);
|
||||
virObjectUnref(vm);
|
||||
VIR_DEBUG("%s: Event handler loop thread exiting", vm->def->name);
|
||||
virObjectUnref(vm);
|
||||
virObjectUnref(mon);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -308,7 +309,6 @@ virCHStartEventHandler(virCHMonitor *mon)
|
||||
virObjectUnref(mon);
|
||||
return -1;
|
||||
}
|
||||
virObjectUnref(mon);
|
||||
|
||||
g_atomic_int_set(&mon->event_handler_stop, 0);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user