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

Frediano Ziglio fziglio at redhat.com
Thu Aug 24 14:37:19 UTC 2017


Allows to access it safely from different threads.

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



More information about the Spice-devel mailing list