[Spice-devel] [PATCH spice 8/9] red-channel: return number of created pipe items

Frediano Ziglio fziglio at redhat.com
Fri Dec 11 03:55:47 PST 2015


> 
> This is useful in the following patches to count the number of replies
> to wait for.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
> ---
>  server/red-channel.c | 21 +++++++++++++--------
>  server/red-channel.h |  2 +-
>  2 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/server/red-channel.c b/server/red-channel.c
> index fcbe868..ff1411f 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -2233,14 +2233,14 @@ int red_client_during_migrate_at_target(RedClient
> *client)
>  typedef void (*rcc_item_t)(RedChannelClient *rcc, PipeItem *item);
>  typedef int (*rcc_item_cond_t)(RedChannelClient *rcc, PipeItem *item);
>  
> -static void red_channel_pipes_create_batch(RedChannel *channel,
> -                                new_pipe_item_t creator, void *data,
> -                                rcc_item_t callback)
> +static int red_channel_pipes_create_batch(RedChannel *channel,
> +                                          new_pipe_item_t creator, void
> *data,
> +                                          rcc_item_t callback)
>  {
>      RingItem *link, *next;
>      RedChannelClient *rcc;
>      PipeItem *item;
> -    int num = 0;
> +    int num = 0, n = 0;
>  
>      spice_assert(callback);
>  
> @@ -2249,16 +2249,21 @@ static void red_channel_pipes_create_batch(RedChannel
> *channel,
>          item = (*creator)(rcc, data, num++);
>          if (item != NULL) {
>              (*callback)(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 609bce3..226de49 100644
> --- a/server/red-channel.h
> +++ b/server/red-channel.h
> @@ -476,7 +476,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

Acked-by: Frediano Ziglio <fziglio at redhat.com>

Frediano


More information about the Spice-devel mailing list