[PATCH 06/10] vireventthread: add virEventThreadClose

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



virEventThreadClose is used when event loop thread should
be exited synchronously (which is not the case when event loop
is just unreferenced).

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 src/libvirt_private.syms  | 1 +
 src/util/vireventthread.c | 9 +++++++++
 src/util/vireventthread.h | 1 +
 3 files changed, 11 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f64b1de..c85ec43 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2023,6 +2023,7 @@ virEventGLibRunOnce;
 
 
 # util/vireventthread.h
+virEventThreadClose;
 virEventThreadGetContext;
 virEventThreadNew;
 
diff --git a/src/util/vireventthread.c b/src/util/vireventthread.c
index cf86592..0a7c436 100644
--- a/src/util/vireventthread.c
+++ b/src/util/vireventthread.c
@@ -183,6 +183,15 @@ virEventThreadNew(const char *name)
 }
 
 
+void
+virEventThreadClose(virEventThread *evt)
+{
+    g_main_loop_quit(evt->loop);
+    g_thread_join(evt->thread);
+    evt->thread = NULL;
+}
+
+
 GMainContext *
 virEventThreadGetContext(virEventThread *evt)
 {
diff --git a/src/util/vireventthread.h b/src/util/vireventthread.h
index 5826c25..6f01629 100644
--- a/src/util/vireventthread.h
+++ b/src/util/vireventthread.h
@@ -27,5 +27,6 @@
 G_DECLARE_FINAL_TYPE(virEventThread, vir_event_thread, VIR, EVENT_THREAD, GObject);
 
 virEventThread *virEventThreadNew(const char *name);
+void virEventThreadClose(virEventThread *evt);
 
 GMainContext *virEventThreadGetContext(virEventThread *evt);
-- 
1.8.3.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux