From: Nikolay Shirokovskiy Date: Thu, 23 Jul 2020 07:23:00 +0000 (+0300) Subject: vireventthread: exit thread synchronously on finalize X-Git-Tag: v6.8.0-rc1~277 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4fc3db9204407874181117085756c9ced78adad;p=thirdparty%2Flibvirt.git vireventthread: exit thread synchronously on finalize 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 Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrangé --- diff --git a/src/util/vireventthread.c b/src/util/vireventthread.c index 485672278a..1bca2aa57a 100644 --- a/src/util/vireventthread.c +++ b/src/util/vireventthread.c @@ -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); }