]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vireventthread: exit thread synchronously on finalize
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Thu, 23 Jul 2020 07:23:00 +0000 (10:23 +0300)
committerNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Mon, 7 Sep 2020 06:33:59 +0000 (09:33 +0300)
It it useful to be sure no thread is running after we drop all references to
virEventThread. Otherwise in order to avoid crashes we need to synchronize some
other way or we make extra references in event handler callbacks to all the
object in use. And some of them are not prepared to be refcounted.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/vireventthread.c

index 485672278add4b859b05fc432ea335df8232b957..1bca2aa57a0d108ea8166f8b82a2d5069d8889a5 100644 (file)
@@ -43,6 +43,7 @@ vir_event_thread_finalize(GObject *object)
 
     if (evt->thread) {
         g_main_loop_quit(evt->loop);
+        g_thread_join(evt->thread);
         g_thread_unref(evt->thread);
     }