[Spice-devel] [PATCH 11/18] worker: add display_channel_free_glz_drawables_to_free()

Frediano Ziglio fziglio at redhat.com
Wed Nov 18 08:17:30 PST 2015


From: Marc-André Lureau <marcandre.lureau at gmail.com>

---
 server/dcc-encoders.c    | 17 +++++++++++++++++
 server/dcc-encoders.h    |  2 ++
 server/display-channel.c | 12 ++++++++++++
 server/display-channel.h |  1 +
 server/red_worker.c      | 27 +--------------------------
 5 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index 305d17e..9104405 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -472,3 +472,20 @@ void dcc_free_glz_drawable_instance(DisplayChannelClient *dcc,
         free(glz_drawable);
     }
 }
+
+void dcc_free_glz_drawables_to_free(DisplayChannelClient* dcc)
+{
+    RingItem *ring_link;
+
+    if (!dcc->glz_dict) {
+        return;
+    }
+    pthread_mutex_lock(&dcc->glz_drawables_inst_to_free_lock);
+    while ((ring_link = ring_get_head(&dcc->glz_drawables_inst_to_free))) {
+        GlzDrawableInstanceItem *drawable_instance = SPICE_CONTAINEROF(ring_link,
+                                                                 GlzDrawableInstanceItem,
+                                                                 free_link);
+        dcc_free_glz_drawable_instance(dcc, drawable_instance);
+    }
+    pthread_mutex_unlock(&dcc->glz_drawables_inst_to_free_lock);
+}
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index c973502..4dc50b1 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -38,6 +38,8 @@ typedef struct GlzDrawableInstanceItem GlzDrawableInstanceItem;
 void             dcc_encoders_init                           (DisplayChannelClient *dcc);
 void             dcc_free_glz_drawable_instance              (DisplayChannelClient *dcc,
                                                               GlzDrawableInstanceItem *item);
+void             dcc_free_glz_drawables_to_free              (DisplayChannelClient* dcc);
+
 void             marshaller_add_compressed                   (SpiceMarshaller *m,
                                                               RedCompressBuf *comp_buf,
                                                               size_t size);
diff --git a/server/display-channel.c b/server/display-channel.c
index ce973c5..a391c29 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -849,3 +849,15 @@ void display_channel_flush_all_surfaces(DisplayChannel *display)
         }
     }
 }
+
+static void rcc_free_glz_drawables_to_free(RedChannelClient *rcc)
+{
+    DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
+
+    dcc_free_glz_drawables_to_free(dcc);
+}
+
+void display_channel_free_glz_drawables_to_free(DisplayChannel *display)
+{
+    red_channel_apply_clients(RED_CHANNEL(display), rcc_free_glz_drawables_to_free);
+}
diff --git a/server/display-channel.h b/server/display-channel.h
index afb9ec5..684f983 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -273,6 +273,7 @@ void                       display_channel_current_flush             (DisplayCha
                                                                       int surface_id);
 int                        display_channel_wait_for_migrate_data     (DisplayChannel *display);
 void                       display_channel_flush_all_surfaces        (DisplayChannel *display);
+void                       display_channel_free_glz_drawables_to_free(DisplayChannel *display);
 
 static inline int is_equal_path(SpicePath *path1, SpicePath *path2)
 {
diff --git a/server/red_worker.c b/server/red_worker.c
index 9318a43..0144124 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -2006,23 +2006,6 @@ static void fill_base(SpiceMarshaller *base_marshaller, Drawable *drawable)
     spice_marshall_DisplayBase(base_marshaller, &base);
 }
 
-static void red_display_handle_glz_drawables_to_free(DisplayChannelClient* dcc)
-{
-    RingItem *ring_link;
-
-    if (!dcc->glz_dict) {
-        return;
-    }
-    pthread_mutex_lock(&dcc->glz_drawables_inst_to_free_lock);
-    while ((ring_link = ring_get_head(&dcc->glz_drawables_inst_to_free))) {
-        GlzDrawableInstanceItem *drawable_instance = SPICE_CONTAINEROF(ring_link,
-                                                                 GlzDrawableInstanceItem,
-                                                                 free_link);
-        dcc_free_glz_drawable_instance(dcc, drawable_instance);
-    }
-    pthread_mutex_unlock(&dcc->glz_drawables_inst_to_free_lock);
-}
-
 /*
  * Releases all the instances of the drawable from the dictionary and the display channel client.
  * The release of the last instance will also release the drawable itself and the qxl drawable
@@ -6834,13 +6817,6 @@ RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher)
     return worker;
 }
 
-static void red_display_cc_free_glz_drawables(RedChannelClient *rcc)
-{
-    DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
-
-    red_display_handle_glz_drawables_to_free(dcc);
-}
-
 SPICE_GNUC_NORETURN static void *red_worker_main(void *arg)
 {
     RedWorker *worker = arg;
@@ -6876,8 +6852,7 @@ SPICE_GNUC_NORETURN static void *red_worker_main(void *arg)
             /* during migration, in the dest, the display channel can be initialized
                while the global lz data not since migrate data msg hasn't been
                received yet */
-            red_channel_apply_clients(&worker->display_channel->common.base,
-                                      red_display_cc_free_glz_drawables);
+            display_channel_free_glz_drawables_to_free(worker->display_channel);
         }
 
         worker->event_timeout = INF_EVENT_WAIT;
-- 
2.4.3



More information about the Spice-devel mailing list