[Spice-commits] 2 commits - server/main-channel-client.c server/red-qxl.h server/red-worker.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Mon Nov 28 19:22:24 UTC 2016


 server/main-channel-client.c |    4 +---
 server/red-qxl.h             |    6 ++++++
 server/red-worker.c          |   18 ++++++++++++++++--
 3 files changed, 23 insertions(+), 5 deletions(-)

New commits:
commit cb3216aa83d9ec65fa95fb18a9523bfc7fca820b
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Nov 18 09:34:12 2016 +0000

    Reuse reds_core_timer_add
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 987f260..576b31f 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -174,9 +174,7 @@ static void main_channel_client_constructed(GObject *object)
     RedsState *reds =
         red_channel_get_server(red_channel_client_get_channel(RED_CHANNEL_CLIENT(object)));
 
-    self->priv->ping_timer =
-        reds_get_core_interface(reds)->timer_add(reds_get_core_interface(reds),
-                                                 ping_timer_cb, self);
+    self->priv->ping_timer = reds_core_timer_add(reds, ping_timer_cb, self);
     if (!self->priv->ping_timer) {
         spice_error("ping timer create failed");
     }
commit afa3144de5fa21ee84f7eb3ffa62c546e128b238
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Nov 17 17:29:51 2016 +0000

    red_worker: add RED_WORKER_MESSAGE_CLOSE_WORKER message
    
    Allows to close worker thread.
    This will be used to destroy cleanly CursorChannel and
    DisplayChannel.
    CursorChannel and DisplayChannel are run in a different
    thread. However deregistration of channels and different
    steps of destruction should be done in the same thread
    so this make possible to join again the 2 threads to
    avoid race conditions.
    For the moment there is no correct cleanup.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/server/red-qxl.h b/server/red-qxl.h
index 0ff2475..65357b1 100644
--- a/server/red-qxl.h
+++ b/server/red-qxl.h
@@ -116,6 +116,9 @@ enum {
     RED_WORKER_MESSAGE_GL_DRAW_ASYNC,
     RED_WORKER_MESSAGE_SET_VIDEO_CODECS,
 
+    /* close worker thread */
+    RED_WORKER_MESSAGE_CLOSE_WORKER,
+
     RED_WORKER_MESSAGE_COUNT // LAST
 };
 
@@ -291,6 +294,9 @@ typedef struct RedWorkerMessageDriverUnload {
 typedef struct RedWorkerMessageGlScanout {
 } RedWorkerMessageGlScanout;
 
+typedef struct RedWorkerMessageClose {
+} RedWorkerMessageClose;
+
 enum {
     RED_DISPATCHER_PENDING_WAKEUP,
     RED_DISPATCHER_PENDING_OOM,
diff --git a/server/red-worker.c b/server/red-worker.c
index f8c135f..d699bd6 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -85,6 +85,7 @@ struct RedWorker {
     int driver_cap_monitors_config;
 
     RedRecord *record;
+    GMainLoop *loop;
 };
 
 static int display_is_connected(RedWorker *worker)
@@ -971,6 +972,12 @@ void handle_dev_gl_draw_async(void *opaque, void *payload)
     display_channel_gl_draw(worker->display_channel, draw);
 }
 
+static void handle_dev_close(void *opaque, void *payload)
+{
+    RedWorker *worker = opaque;
+    g_main_loop_quit(worker->loop);
+}
+
 static int loadvm_command(RedWorker *worker, QXLCommandExt *ext)
 {
     RedCursorCmd *cursor_cmd;
@@ -1222,6 +1229,11 @@ static void register_callbacks(Dispatcher *dispatcher)
                                 handle_dev_gl_draw_async,
                                 sizeof(SpiceMsgDisplayGlDraw),
                                 DISPATCHER_NONE);
+    dispatcher_register_handler(dispatcher,
+                                RED_WORKER_MESSAGE_CLOSE_WORKER,
+                                handle_dev_close,
+                                sizeof(RedWorkerMessageClose),
+                                DISPATCHER_NONE);
 }
 
 
@@ -1381,7 +1393,7 @@ RedWorker* red_worker_new(QXLInstance *qxl,
     return worker;
 }
 
-SPICE_GNUC_NORETURN static void *red_worker_main(void *arg)
+static void *red_worker_main(void *arg)
 {
     RedWorker *worker = arg;
 
@@ -1393,11 +1405,13 @@ SPICE_GNUC_NORETURN static void *red_worker_main(void *arg)
     red_channel_reset_thread_id(RED_CHANNEL(worker->display_channel));
 
     GMainLoop *loop = g_main_loop_new(worker->core.main_context, FALSE);
+    worker->loop = loop;
     g_main_loop_run(loop);
     g_main_loop_unref(loop);
+    worker->loop = NULL;
 
     /* FIXME: free worker, and join threads */
-    exit(0);
+    return NULL;
 }
 
 bool red_worker_run(RedWorker *worker)


More information about the Spice-commits mailing list