[PATCH spice-server v2 5/7] red-client: Automatically set MainChannelClient

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

 



This make sure that the RedClient has always an attached
MainChannelClient.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/red-client.c           | 11 +++++------
 server/red-client.h           |  2 --
 server/reds.c                 |  1 -
 server/tests/test-channel.c   |  1 -
 server/tests/test-smartcard.c |  1 -
 5 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/server/red-client.c b/server/red-client.c
index 476f6f5be..6cbfa72b4 100644
--- a/server/red-client.c
+++ b/server/red-client.c
@@ -295,6 +295,11 @@ gboolean red_client_add_channel(RedClient *client, RedChannelClient *rcc, GError
         goto cleanup;
     }
 
+    // first must be the main one
+    if (!client->mcc) {
+        client->mcc = g_object_ref(rcc);
+        spice_assert(MAIN_CHANNEL_CLIENT(rcc) != NULL);
+    }
     client->channels = g_list_prepend(client->channels, rcc);
     if (client->during_target_migrate && client->seamless_migrate) {
         if (red_channel_client_set_migration_seamless(rcc)) {
@@ -312,12 +317,6 @@ MainChannelClient *red_client_get_main(RedClient *client)
     return client->mcc;
 }
 
-void red_client_set_main(RedClient *client, MainChannelClient *mcc)
-{
-    spice_assert(client->mcc == NULL);
-    client->mcc = g_object_ref(mcc);
-}
-
 void red_client_semi_seamless_migrate_complete(RedClient *client)
 {
     RedChannelClient *rcc;
diff --git a/server/red-client.h b/server/red-client.h
index 3ee7accb1..e3c04f438 100644
--- a/server/red-client.h
+++ b/server/red-client.h
@@ -39,8 +39,6 @@ gboolean red_client_add_channel(RedClient *client, RedChannelClient *rcc, GError
 void red_client_remove_channel(RedChannelClient *rcc);
 
 MainChannelClient *red_client_get_main(RedClient *client);
-// main should be set once before all the other channels are created
-void red_client_set_main(RedClient *client, MainChannelClient *mcc);
 
 /* called when the migration handshake results in seamless migration (dst side).
  * By default we assume semi-seamless */
diff --git a/server/reds.c b/server/reds.c
index 990da391e..710669721 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1901,7 +1901,6 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
     red_channel_capabilities_reset(&caps);
     spice_debug("NEW Client %p mcc %p connect-id %d", client, mcc, connection_id);
     g_free(link_mess);
-    red_client_set_main(client, mcc);
 
     if (reds->vdagent) {
         if (mig_target) {
diff --git a/server/tests/test-channel.c b/server/tests/test-channel.c
index 372c8d79f..5923d314f 100644
--- a/server/tests/test-channel.c
+++ b/server/tests/test-channel.c
@@ -289,7 +289,6 @@ static void channel_loop(void)
     mcc = main_channel_link(main_channel, client, create_dummy_stream(server, NULL),
                             0, FALSE, &caps);
     g_assert_nonnull(mcc);
-    red_client_set_main(client, mcc);
 
     // inject a trace into the core interface to count the events
     SpiceCoreInterfaceInternal *server_core = reds_get_core_interface(server);
diff --git a/server/tests/test-smartcard.c b/server/tests/test-smartcard.c
index c1e4786da..f102452f4 100644
--- a/server/tests/test-smartcard.c
+++ b/server/tests/test-smartcard.c
@@ -337,7 +337,6 @@ static void test_smartcard(TestFixture *fixture, gconstpointer user_data)
     mcc = main_channel_link(main_channel, client, create_dummy_stream(server, NULL),
                             0, FALSE, &caps);
     g_assert_nonnull(mcc);
-    red_client_set_main(client, mcc);
 
     // create our testing RedChannelClient
     red_channel_connect(channel, client, create_dummy_stream(server, &client_socket),
-- 
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]