[virt-tools-list] [virt-viewer][PATCH 1/6] events: Register event using GOnce to avoid multiple initializations
Fabiano Fidêncio
fidencio at redhat.com
Fri Jul 17 14:01:18 UTC 2015
Based on
http://libvirt.org/git/?p=libvirt-glib.git;a=commit;h=8f8d9ce5238dbcbce40aa04ba55b8c55f97c79c0
Related to: rhbz#1243228
---
src/virt-viewer-events.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/virt-viewer-events.c b/src/virt-viewer-events.c
index 3b5a136..6154353 100644
--- a/src/virt-viewer-events.c
+++ b/src/virt-viewer-events.c
@@ -346,14 +346,22 @@ virt_viewer_events_remove_timeout(int timer)
return 0;
}
-
-void virt_viewer_events_register(void) {
+static gpointer event_register_once(gpointer data G_GNUC_UNUSED)
+{
virEventRegisterImpl(virt_viewer_events_add_handle,
virt_viewer_events_update_handle,
virt_viewer_events_remove_handle,
virt_viewer_events_add_timeout,
virt_viewer_events_update_timeout,
virt_viewer_events_remove_timeout);
+
+ return NULL;
+}
+
+void virt_viewer_events_register(void) {
+ static GOnce once = G_ONCE_INIT;
+
+ g_once(&once, event_register_once, NULL);
}
/*
--
2.4.4
More information about the virt-tools-list
mailing list