Re: [PATCH spice-server 4/5] red-client: Protect disconnecting with a lock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 24, 2017 at 03:37:19PM +0100, Frediano Ziglio wrote:
> Allows to access it safely from different threads.

I guess it would be worth mentioning the code paths where it's needed in
the commit log.

Christophe

> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/red-client.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/server/red-client.c b/server/red-client.c
> index 666903e3..3ce09e33 100644
> --- a/server/red-client.c
> +++ b/server/red-client.c
> @@ -347,12 +347,18 @@ gboolean red_client_seamless_migration_done_for_channel(RedClient *client)
>  
>  gboolean red_client_is_disconnecting(RedClient *client)
>  {
> -    return client->disconnecting;
> +    gboolean ret;
> +    pthread_mutex_lock(&client->lock);
> +    ret =  client->disconnecting;
> +    pthread_mutex_unlock(&client->lock);
> +    return ret;
>  }
>  
>  void red_client_set_disconnecting(RedClient *client)
>  {
> +    pthread_mutex_lock(&client->lock);
>      client->disconnecting = TRUE;
> +    pthread_mutex_unlock(&client->lock);
>  }
>  
>  RedsState *red_client_get_server(RedClient *client)
> -- 
> 2.13.5
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]