[Spice-devel] [PATCH spice-gtk 1/2] Set channel state before calling channel_reset

Hans de Goede hdegoede at redhat.com
Fri Sep 28 11:13:46 PDT 2012


This way functions called from the channel_reset function can rely
on state acurately reflecting the state. This is necessary to stop
channel-usbredir's reset callback from trying to send the initial
hello message while the channel is no longer in a connected state.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 gtk/spice-channel.c | 2 +-
 gtk/spice-session.c | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index dee0fa3..c5e8d9f 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2428,10 +2428,10 @@ static void channel_disconnect(SpiceChannel *channel)
     if (c->state == SPICE_CHANNEL_STATE_READY)
         emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_CLOSED);
 
+    c->state = SPICE_CHANNEL_STATE_UNCONNECTED;
     spice_channel_reset(channel, FALSE);
 
     g_return_if_fail(SPICE_IS_CHANNEL(channel));
-    c->state = SPICE_CHANNEL_STATE_UNCONNECTED;
 }
 
 /**
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 68d1594..28ebe8a 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1388,15 +1388,17 @@ void spice_session_migrate_end(SpiceSession *self)
         SpiceChannel *channel = l->data;
         l = l->next;
 
+        if (!SPICE_IS_MAIN_CHANNEL(channel)) {
+            /* freeze other channels */
+            channel->priv->state = SPICE_CHANNEL_STATE_MIGRATING;
+        }
+
         /* reset for migration, disconnect */
         spice_channel_reset(channel, TRUE);
 
         if (SPICE_IS_MAIN_CHANNEL(channel)) {
             /* migrate main to target, so we can start talking */
             spice_session_channel_migrate(self, channel);
-        } else {
-            /* freeze other channels */
-            channel->priv->state = SPICE_CHANNEL_STATE_MIGRATING;
         }
     }
 
-- 
1.7.12



More information about the Spice-devel mailing list