[Spice-devel] [PATCH spice-server 4/5] red-client: Protect disconnecting with a lock
Christophe Fergeau
cfergeau at redhat.com
Fri Aug 25 14:13:16 UTC 2017
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 at redhat.com>
> ---
> 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 at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list