[Spice-devel] [PATCH 01/11] Add red_client_seamless_migration_done_for_channel()

Pavel Grunt pgrunt at redhat.com
Fri May 13 07:37:29 UTC 2016


On Thu, 2016-05-12 at 15:45 -0500, Jonathon Jongsma wrote:
> This is a public RedClient API that handles updating itself rather than
> having the RedChannelClient poke around at the internal structure in
> rec_channel_client_seamless_migration_done().

Acked-by: Pavel Grunt <pgrunt at redhat.com>

> ---
>  server/red-channel.c | 34 ++++++++++++++++++++++------------
>  1 file changed, 22 insertions(+), 12 deletions(-)
> 
> diff --git a/server/red-channel.c b/server/red-channel.c
> index a99c6c6..66aed41 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -939,23 +939,34 @@ error:
>      return NULL;
>  }
>  
> -static void red_channel_client_seamless_migration_done(RedChannelClient *rcc)
> +/* returns TRUE If all channels are finished migrating, FALSE otherwise */
> +static gboolean red_client_seamless_migration_done_for_channel(RedClient
> *client)
>  {
> -    RedsState *reds = red_channel_get_server(rcc->channel);
> -    rcc->wait_migrate_data = FALSE;
> -
> -    pthread_mutex_lock(&rcc->client->lock);
> -    rcc->client->num_migrated_channels--;
> +    gboolean ret = FALSE;
>  
> +    pthread_mutex_lock(&client->lock);
> +    client->num_migrated_channels--;
>      /* we assume we always have at least one channel who has migration data
> transfer,
>       * otherwise, this flag will never be set back to FALSE*/
> -    if (!rcc->client->num_migrated_channels) {
> -        rcc->client->during_target_migrate = FALSE;
> -        rcc->client->seamless_migrate = FALSE;
> +    if (!client->num_migrated_channels) {
> +        client->during_target_migrate = FALSE;
> +        client->seamless_migrate = FALSE;
>          /* migration completion might have been triggered from a different
> thread
>           * than the main thread */
> -        main_dispatcher_seamless_migrate_dst_complete(reds_get_main_dispatche
> r(reds),
> -                                                      rcc->client);
> +        main_dispatcher_seamless_migrate_dst_complete(reds_get_main_dispatche
> r(client->reds),
> +                                                      client);
> +        ret = TRUE;
> +    }
> +    pthread_mutex_unlock(&client->lock);
> +
> +    return ret;
> +}
> +
> +static void red_channel_client_seamless_migration_done(RedChannelClient *rcc)
> +{
> +    rcc->wait_migrate_data = FALSE;
> +
> +    if (red_client_seamless_migration_done_for_channel(rcc->client)) {
>          if (rcc->latency_monitor.timer) {
>              red_channel_client_start_ping_timer(rcc,
> PING_TEST_IDLE_NET_TIMEOUT_MS);
>          }
> @@ -964,7 +975,6 @@ static void
> red_channel_client_seamless_migration_done(RedChannelClient *rcc)
>                                              rcc-
> >connectivity_monitor.timeout);
>          }
>      }
> -    pthread_mutex_unlock(&rcc->client->lock);
>  }
>  
>  int red_channel_client_is_waiting_for_migrate_data(RedChannelClient *rcc)


More information about the Spice-devel mailing list