[Spice-devel] [PATCH v4] !fixup Improve MainChannel encapsulation

Jonathon Jongsma jjongsma at redhat.com
Tue Oct 18 16:39:58 UTC 2016


---
Changes since v3:
 - change _peek_migration_target() to _get_migration_target()
 - add separate 'success' argument to _on_migrate_connected()
 - revert to using asserts


 server/main-channel-client.c |  6 +++---
 server/main-channel.c        | 12 +++++++-----
 server/main-channel.h        |  4 ++--
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 28d2839..b47b1e0 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -439,7 +439,7 @@ void main_channel_client_handle_migrate_connected(MainChannelClient *mcc,
 
         mcc->priv->mig_wait_connect = FALSE;
         mcc->priv->mig_connect_ok = success;
-        main_channel_on_migrate_connected(main_channel, seamless && success);
+        main_channel_on_migrate_connected(main_channel, success, seamless);
     } else {
         if (success) {
             spice_printerr("client %p MIGRATE_CANCEL", client);
@@ -872,7 +872,7 @@ static void main_channel_marshall_notify(RedChannelClient *rcc,
 static void main_channel_fill_migrate_dst_info(MainChannel *main_channel,
                                                SpiceMigrationDstInfo *dst_info)
 {
-    const RedsMigSpice *mig_dst = main_channel_peek_migration_target(main_channel);
+    const RedsMigSpice *mig_dst = main_channel_get_migration_target(main_channel);
     dst_info->port = mig_dst->port;
     dst_info->sport = mig_dst->sport;
     dst_info->host_size = strlen(mig_dst->host) + 1;
@@ -936,7 +936,7 @@ static void main_channel_marshall_migrate_switch(SpiceMarshaller *m, RedChannelC
     spice_printerr("");
     red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST, item);
     main_ch = SPICE_CONTAINEROF(channel, MainChannel, base);
-    mig_target = main_channel_peek_migration_target(main_ch);
+    mig_target = main_channel_get_migration_target(main_ch);
     migrate.port = mig_target->port;
     migrate.sport = mig_target->sport;
     migrate.host_size = strlen(mig_target->host) + 1;
diff --git a/server/main-channel.c b/server/main-channel.c
index 2d2783d..0b90c32 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -420,17 +420,19 @@ int main_channel_migrate_src_complete(MainChannel *main_chan, int success)
    return semi_seamless_count;
 }
 
-void main_channel_on_migrate_connected(MainChannel *main_channel, gboolean seamless)
+void main_channel_on_migrate_connected(MainChannel *main_channel,
+                                       gboolean success,
+                                       gboolean seamless)
 {
-        g_return_if_fail(main_channel->num_clients_mig_wait);
-        g_warn_if_fail(!seamless || main_channel->num_clients_mig_wait == 1);
+        spice_assert(main_channel->num_clients_mig_wait);
+        spice_assert(!seamless || main_channel->num_clients_mig_wait == 1);
         if (!--main_channel->num_clients_mig_wait) {
             reds_on_main_migrate_connected(red_channel_get_server(RED_CHANNEL(main_channel)),
-                                           seamless);
+                                           seamless && success);
         }
 }
 
-const RedsMigSpice* main_channel_peek_migration_target(MainChannel *main_chan)
+const RedsMigSpice* main_channel_get_migration_target(MainChannel *main_chan)
 {
     return &main_chan->mig_target;
 }
diff --git a/server/main-channel.h b/server/main-channel.h
index 529e7be..99022c7 100644
--- a/server/main-channel.h
+++ b/server/main-channel.h
@@ -78,9 +78,9 @@ void main_channel_migrate_switch(MainChannel *main_chan, RedsMigSpice *mig_targe
 int main_channel_migrate_connect(MainChannel *main_channel, RedsMigSpice *mig_target,
                                  int try_seamless);
 void main_channel_migrate_cancel_wait(MainChannel *main_chan);
-const RedsMigSpice* main_channel_peek_migration_target(MainChannel *main_chan);
+const RedsMigSpice* main_channel_get_migration_target(MainChannel *main_chan);
 /* returns the number of clients for which SPICE_MSG_MAIN_MIGRATE_END was sent*/
 int main_channel_migrate_src_complete(MainChannel *main_chan, int success);
-void main_channel_on_migrate_connected(MainChannel *main_channel, gboolean seamless);
+void main_channel_on_migrate_connected(MainChannel *main_channel, gboolean success, gboolean seamless);
 
 #endif
-- 
2.7.4



More information about the Spice-devel mailing list