[Spice-devel] [PATCH 07/10] worker: move remove worker from WORKER_FOREACH_DCC_SAFE

Frediano Ziglio fziglio at redhat.com
Thu Nov 5 01:15:00 PST 2015


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

---
 server/red_worker.c | 38 ++++++++++++++++++--------------------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index 32611e2..480f2ca 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -583,10 +583,8 @@ static void dcc_push_monitors_config(DisplayChannelClient *dcc);
     SAFE_FOREACH(link, next, channel,  &(channel)->clients, dcc, LINK_TO_DCC(link))
 
 
-#define WORKER_FOREACH_DCC_SAFE(worker, link, next, dcc)      \
-    DCC_FOREACH_SAFE(link, next, dcc,                         \
-                ((((worker) && (worker)->display_channel))?   \
-                 (&(worker)->display_channel->common.base) : NULL))
+#define FOREACH_DCC(display_channel, link, next, dcc)      \
+    DCC_FOREACH_SAFE(link, next, dcc, RED_CHANNEL(display_channel))
 
 
 #define LINK_TO_DPI(ptr) SPICE_CONTAINEROF((ptr), DrawablePipeItem, base)
@@ -842,7 +840,7 @@ static void red_pipes_add_drawable(RedWorker *worker, Drawable *drawable)
     RingItem *dcc_ring_item, *next;
 
     spice_warn_if(!ring_is_empty(&drawable->pipes));
-    WORKER_FOREACH_DCC_SAFE(worker, dcc_ring_item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, dcc_ring_item, next, dcc) {
         dcc_add_drawable(dcc, drawable);
     }
 }
@@ -882,7 +880,7 @@ static inline void red_pipes_add_drawable_after(RedWorker *worker,
     if (num_other_linked != worker->display_channel->common.base.clients_num) {
         RingItem *worker_item, *next;
         spice_debug("TODO: not O(n^2)");
-        WORKER_FOREACH_DCC_SAFE(worker, worker_item, next, dcc) {
+        FOREACH_DCC(worker->display_channel, worker_item, next, dcc) {
             int sent = 0;
             DRAWABLE_FOREACH_DPI_SAFE(pos_after, dpi_link, dpi_next, dpi_pos_after) {
                 if (dpi_pos_after->dcc == dcc) {
@@ -1075,7 +1073,7 @@ static inline void red_destroy_surface(RedWorker *worker, uint32_t surface_id)
 
         region_destroy(&surface->draw_dirty_region);
         surface->context.canvas = NULL;
-        WORKER_FOREACH_DCC_SAFE(worker, link, next, dcc) {
+        FOREACH_DCC(worker->display_channel, link, next, dcc) {
             red_destroy_surface_item(worker, dcc, surface_id);
         }
 
@@ -1409,7 +1407,7 @@ static void red_clear_surface_drawables_from_pipes(RedWorker *worker,
     RingItem *item, *next;
     DisplayChannelClient *dcc;
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         if (!red_clear_surface_drawables_from_pipe(dcc, surface_id, wait_if_used)) {
             red_channel_client_disconnect(&dcc->common.base);
         }
@@ -1771,7 +1769,7 @@ static void red_attach_stream(RedWorker *worker, Drawable *drawable, Stream *str
         stream->num_input_frames++;
     }
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         StreamAgent *agent;
         QRegion clip_in_draw_dest;
 
@@ -1837,7 +1835,7 @@ static void red_stop_stream(RedWorker *worker, Stream *stream)
     spice_assert(ring_item_is_linked(&stream->link));
     spice_assert(!stream->current);
     spice_debug("stream %d", get_stream_id(worker, stream));
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         StreamAgent *stream_agent;
 
         stream_agent = &dcc->stream_agents[get_stream_id(worker, stream)];
@@ -1954,7 +1952,7 @@ static inline void red_detach_stream_gracefully(RedWorker *worker, Stream *strea
     RingItem *item, *next;
     DisplayChannelClient *dcc;
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         red_display_detach_stream_gracefully(dcc, stream, update_area_limit);
     }
     if (stream->current) {
@@ -1985,7 +1983,7 @@ static void red_detach_streams_behind(RedWorker *worker, QRegion *region, Drawab
         int detach_stream = 0;
         item = ring_next(ring, item);
 
-        WORKER_FOREACH_DCC_SAFE(worker, dcc_ring_item, next, dcc) {
+        FOREACH_DCC(worker->display_channel, dcc_ring_item, next, dcc) {
             StreamAgent *agent = &dcc->stream_agents[get_stream_id(worker, stream)];
 
             if (region_intersects(&agent->vis_region, region)) {
@@ -2033,7 +2031,7 @@ static void red_streams_update_visible_region(RedWorker *worker, Drawable *drawa
             continue;
         }
 
-        WORKER_FOREACH_DCC_SAFE(worker, dcc_ring_item, next, dcc) {
+        FOREACH_DCC(worker->display_channel, dcc_ring_item, next, dcc) {
             agent = &dcc->stream_agents[get_stream_id(worker, stream)];
 
             if (region_intersects(&agent->vis_region, &drawable->tree_item.base.rgn)) {
@@ -2306,7 +2304,7 @@ static void red_create_stream(RedWorker *worker, Drawable *drawable)
     stream->input_fps_start_time = drawable->creation_time;
     worker->streams_size_total += stream->width * stream->height;
     worker->stream_count++;
-    WORKER_FOREACH_DCC_SAFE(worker, dcc_ring_item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, dcc_ring_item, next, dcc) {
         red_display_create_stream(dcc, stream);
     }
     spice_debug("stream %d %dx%d (%d, %d) (%d, %d)", (int)(stream - worker->streams_buf), stream->width,
@@ -2499,7 +2497,7 @@ static inline void pre_stream_item_swap(RedWorker *worker, Stream *stream, Drawa
     }
 
 
-    WORKER_FOREACH_DCC_SAFE(worker, ring_item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, ring_item, next, dcc) {
         double drop_factor;
 
         agent = &dcc->stream_agents[index];
@@ -3996,7 +3994,7 @@ static void red_free_some(RedWorker *worker)
 
     spice_debug("#draw=%d, #red_draw=%d, #glz_draw=%d", worker->drawable_count,
                 worker->red_drawable_count, worker->glz_drawable_count);
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         GlzSharedDictionary *glz_dict = dcc ? dcc->glz_dict : NULL;
 
         if (glz_dict) {
@@ -4011,7 +4009,7 @@ static void red_free_some(RedWorker *worker)
         free_one_drawable(worker, TRUE);
     }
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         GlzSharedDictionary *glz_dict = dcc ? dcc->glz_dict : NULL;
 
         if (glz_dict) {
@@ -8173,7 +8171,7 @@ static void red_worker_create_surface_item(RedWorker *worker, int surface_id)
     DisplayChannelClient *dcc;
     RingItem *item, *next;
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         red_create_surface_item(dcc, surface_id);
     }
 }
@@ -8184,7 +8182,7 @@ static void red_worker_push_surface_image(RedWorker *worker, int surface_id)
     DisplayChannelClient *dcc;
     RingItem *item, *next;
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         red_push_surface_image(dcc, surface_id);
     }
 }
@@ -9570,7 +9568,7 @@ static void red_worker_push_monitors_config(RedWorker *worker)
     DisplayChannelClient *dcc;
     RingItem *item, *next;
 
-    WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
+    FOREACH_DCC(worker->display_channel, item, next, dcc) {
         dcc_push_monitors_config(dcc);
     }
 }
-- 
2.4.3



More information about the Spice-devel mailing list