[Spice-devel] [PATCH server v2 08/13] red-channel: return number of created pipe items

Frediano Ziglio fziglio at redhat.com
Fri Jan 22 05:05:50 PST 2016


> 
> This is useful in the following patches to count the number of replies
> to wait for.
> 

I was looking at the entire set of patches.

I think the gl_draw_async_count counter is much better be incremented before
sending the PIPE_ITEM_TYPE_GL_DRAW.
This will avoid entirely this patch.
Also looks more correct to me as this counter is used to check that client is
not sending a DRAW_DONE for a not sent DRAW.
For instance can happen that the item is still on the queue to be send and
you accept the DRAW_DONE for it.

Frediano

> Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
> ---
>  server/red-channel.c | 19 +++++++++++++------
>  server/red-channel.h |  2 +-
>  2 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/server/red-channel.c b/server/red-channel.c
> index ceceb7f..fe38360 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -2246,15 +2246,17 @@ typedef int (*rcc_item_cond_t)(RedChannelClient *rcc,
> PipeItem *item);
>   * @creator: a callback to create pipe item (not null)
>   * @data: the data to pass to the creator
>   * @pipe_add: a callback to add non-null pipe items (not null)
> + *
> + * Returns: the number of added items
>   **/
> -static void red_channel_pipes_create_batch(RedChannel *channel,
> +static int red_channel_pipes_create_batch(RedChannel *channel,
>                                  new_pipe_item_t creator, void *data,
>                                  rcc_item_t pipe_add)
>  {
>      RingItem *link, *next;
>      RedChannelClient *rcc;
>      PipeItem *item;
> -    int num = 0;
> +    int num = 0, n = 0;
>  
>      spice_assert(creator != NULL);
>      spice_assert(pipe_add != NULL);
> @@ -2264,16 +2266,21 @@ static void red_channel_pipes_create_batch(RedChannel
> *channel,
>          item = (*creator)(rcc, data, num++);
>          if (item) {
>              (*pipe_add)(rcc, item);
> +            n++;
>          }
>      }
> +
> +    return n;
>  }
>  
> -void red_channel_pipes_new_add_push(RedChannel *channel,
> -                              new_pipe_item_t creator, void *data)
> +int red_channel_pipes_new_add_push(RedChannel *channel,
> +                                   new_pipe_item_t creator, void *data)
>  {
> -    red_channel_pipes_create_batch(channel, creator, data,
> -                                     red_channel_client_pipe_add);
> +    int n = red_channel_pipes_create_batch(channel, creator, data,
> +                                           red_channel_client_pipe_add);
>      red_channel_push(channel);
> +
> +    return n;
>  }
>  
>  void red_channel_pipes_new_add(RedChannel *channel, new_pipe_item_t creator,
>  void *data)
> diff --git a/server/red-channel.h b/server/red-channel.h
> index 791bc5b..fbb93b7 100644
> --- a/server/red-channel.h
> +++ b/server/red-channel.h
> @@ -478,7 +478,7 @@ void red_channel_pipe_item_init(RedChannel *channel,
> PipeItem *item, int type);
>  
>  // helper to push a new item to all channels
>  typedef PipeItem *(*new_pipe_item_t)(RedChannelClient *rcc, void *data, int
>  num);
> -void red_channel_pipes_new_add_push(RedChannel *channel, new_pipe_item_t
> creator, void *data);
> +int red_channel_pipes_new_add_push(RedChannel *channel, new_pipe_item_t
> creator, void *data);
>  void red_channel_pipes_new_add(RedChannel *channel, new_pipe_item_t creator,
>  void *data);
>  void red_channel_pipes_new_add_tail(RedChannel *channel, new_pipe_item_t
>  creator, void *data);
>  
> --
> 2.5.0
> 
> 


More information about the Spice-devel mailing list