[Spice-devel] [PATCH 17/26] server/red_channel: add red_channel_{, no_}item_being_sent

Marc-André Lureau marcandre.lureau at gmail.com
Mon Feb 14 17:29:23 PST 2011


Ok, I am not sure if the imposed synchronization between the channels
is the right choice, but perhaps this is only a first approach.

On Fri, Feb 11, 2011 at 6:49 PM, Alon Levy <alevy at redhat.com> wrote:
> ---
>  server/red_channel.c |   10 ++++++++++
>  server/red_channel.h |    8 ++++++++
>  server/red_worker.c  |   10 +++++-----
>  3 files changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/server/red_channel.c b/server/red_channel.c
> index 061c9c3..f570960 100644
> --- a/server/red_channel.c
> +++ b/server/red_channel.c
> @@ -727,3 +727,13 @@ int red_channel_send_message_pending(RedChannel *channel)
>     return channel->send_data.header->type != 0;
>  }
>
> +int red_channel_item_being_sent(RedChannel *channel, PipeItem *item)
> +{
> +    return channel->send_data.item == item;
> +}
> +
> +int red_channel_no_item_being_sent(RedChannel *channel)
> +{
> +    return channel->send_data.item == NULL;
> +}
> +
> diff --git a/server/red_channel.h b/server/red_channel.h
> index 5c776fe..02f81fc 100644
> --- a/server/red_channel.h
> +++ b/server/red_channel.h
> @@ -262,6 +262,14 @@ int red_channel_any_blocked(RedChannel *channel);
>  /* helper for channels that have complex logic that can possibly ready a send */
>  int red_channel_send_message_pending(RedChannel *channel);
>
> +/* returns TRUE if item is being sent by one of the channel clients. This will
> + * be true if someone called init_send_data but send has not completed (or perhaps
> + * hasn't even begun, i.e. no one called begin_send_)
> + * */
> +int red_channel_item_being_sent(RedChannel *channel, PipeItem *item);
> +
> +int red_channel_no_item_being_sent(RedChannel *channel);
> +
>  // TODO: unstaticed for display/cursor channels. they do some specific pushes not through
>  // adding elements or on events. but not sure if this is actually required (only result
>  // should be that they ""try"" a little harder, but if the event system is correct it
> diff --git a/server/red_worker.c b/server/red_worker.c
> index e5117cd..89fede2 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -9438,7 +9438,7 @@ static void red_wait_pipe_item_sent(RedChannel *channel, PipeItem *item)
>         red_printf("timeout");
>         channel->disconnect(channel);
>     } else {
> -        if (channel->send_data.item == item) {
> +        if (red_channel_item_being_sent(channel, item)) {
>             red_wait_outgoing_item(channel);
>         }
>     }
> @@ -9524,7 +9524,7 @@ static inline void destroy_surface_wait(RedWorker *worker, int surface_id)
>     // there is one during sending.
>     red_wait_outgoing_item((RedChannel *)worker->display_channel);
>     if (worker->display_channel) {
> -        ASSERT(!worker->display_channel->common.base.send_data.item);
> +        ASSERT(red_channel_no_item_being_sent(&worker->display_channel->common.base));
>     }
>  }
>
> @@ -9572,7 +9572,7 @@ static inline void handle_dev_destroy_surfaces(RedWorker *worker)
>         if (!worker->cursor_channel->common.base.migrate) {
>             red_pipe_add_verb(&worker->cursor_channel->common.base, SPICE_MSG_CURSOR_RESET);
>         }
> -        ASSERT(!worker->cursor_channel->common.base.send_data.item);
> +        ASSERT(red_channel_no_item_being_sent(&worker->cursor_channel->common.base));
>     }
>
>     if (worker->display_channel) {
> @@ -9648,7 +9648,7 @@ static inline void handle_dev_destroy_primary_surface(RedWorker *worker)
>         if (!worker->cursor_channel->common.base.migrate) {
>             red_pipe_add_verb(&worker->cursor_channel->common.base, SPICE_MSG_CURSOR_RESET);
>         }
> -        ASSERT(!worker->cursor_channel->common.base.send_data.item);
> +        ASSERT(red_channel_no_item_being_sent(&worker->cursor_channel->common.base));
>     }
>
>     flush_all_qxl_commands(worker);
> @@ -9710,7 +9710,7 @@ static void handle_dev_input(EventListener *listener, uint32_t events)
>             if (!cursor_red_channel->migrate) {
>                 red_pipe_add_verb(cursor_red_channel, SPICE_MSG_CURSOR_RESET);
>             }
> -            ASSERT(!cursor_red_channel->send_data.item);
> +            ASSERT(red_channel_no_item_being_sent(cursor_red_channel));
>
>             worker->cursor_visible = TRUE;
>             worker->cursor_position.x = worker->cursor_position.y = 0;
> --
> 1.7.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>



-- 
Marc-André Lureau


More information about the Spice-devel mailing list