[PATCH spice-server v2 4/7] red-client: Make sure MainChannelClient is freed as last

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

 



MainChannelClient is used by other clients to store some data
so should not disappear if other clients are still present.
Keep a owning reference to it and release after RedClient is
released.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/red-client.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/server/red-client.c b/server/red-client.c
index d73d0f8d0..476f6f5be 100644
--- a/server/red-client.c
+++ b/server/red-client.c
@@ -106,6 +106,7 @@ red_client_finalize (GObject *object)
 {
     RedClient *self = RED_CLIENT(object);
 
+    g_clear_object(&self->mcc);
     spice_debug("release client=%p", self);
     pthread_mutex_destroy(&self->lock);
 
@@ -313,7 +314,8 @@ MainChannelClient *red_client_get_main(RedClient *client)
 
 void red_client_set_main(RedClient *client, MainChannelClient *mcc)
 {
-    client->mcc = mcc;
+    spice_assert(client->mcc == NULL);
+    client->mcc = g_object_ref(mcc);
 }
 
 void red_client_semi_seamless_migrate_complete(RedClient *client)
-- 
2.21.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




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