[Spice-devel] [RFC PATCH] initialize global images at load time

Frediano Ziglio fziglio at redhat.com
Fri Feb 26 10:37:21 UTC 2016


This make sure these stuff are initialized without using runtime
resources.
Also make sure stuff are initialize really earlier.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-dispatcher.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index c2ca6b6..d09d56d 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -902,6 +902,12 @@ void red_dispatcher_async_complete(struct RedDispatcher *dispatcher,
     free(async_command);
 }
 
+static void __attribute__((constructor)) red_dispatcher_global_init(void)
+{
+    quic_init();
+    sw_canvas_init();
+}
+
 void red_dispatcher_init(QXLInstance *qxl)
 {
     RedDispatcher *red_dispatcher;
@@ -911,13 +917,6 @@ void red_dispatcher_init(QXLInstance *qxl)
     spice_return_if_fail(qxl != NULL);
     spice_return_if_fail(qxl->st->dispatcher == NULL);
 
-    static gsize initialized = FALSE;
-    if (g_once_init_enter(&initialized)) {
-        quic_init();
-        sw_canvas_init();
-        g_once_init_leave(&initialized, TRUE);
-    }
-
     red_dispatcher = spice_new0(RedDispatcher, 1);
     red_dispatcher->qxl = qxl;
     dispatcher_init(&red_dispatcher->dispatcher, RED_WORKER_MESSAGE_COUNT, NULL);
-- 
2.5.0



More information about the Spice-devel mailing list