[Spice-devel] [PATCH 06/10] worker: move remove worker from WORKER_FOREACH_DCC_SAFE
Frediano Ziglio
fziglio at redhat.com
Fri Nov 6 01:40:17 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 a089a25..b7de808 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -550,10 +550,8 @@ static void
> display_channel_client_release_item_after_push(DisplayChannelClient
> 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)
> @@ -809,7 +807,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);
> }
> }
> @@ -849,7 +847,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) {
> @@ -1042,7 +1040,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);
> }
>
> @@ -1376,7 +1374,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);
> }
> @@ -1738,7 +1736,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;
>
> @@ -1804,7 +1802,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)];
> @@ -1921,7 +1919,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) {
> @@ -1952,7 +1950,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)) {
> @@ -2000,7 +1998,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)) {
> @@ -2273,7 +2271,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,
> @@ -2466,7 +2464,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];
> @@ -3963,7 +3961,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) {
> @@ -3978,7 +3976,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) {
> @@ -8140,7 +8138,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);
> }
> }
> @@ -8151,7 +8149,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);
> }
> }
> @@ -9497,7 +9495,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
>
Merged
Frediano
More information about the Spice-devel
mailing list