[Spice-devel] [PATCH spice-gtk v2 06/19] migration: set connecting state before fd request

Marc-André Lureau marcandre.lureau at redhat.com
Thu Nov 13 15:32:29 PST 2014


During migration, the main channel initiating the process is waiting on
connection completion of all channels in migrate_channel_event_cb() or
it will abort migration for unexpected channel events, such as
SPICE_CHANNEL_CLOSED.

If the migration is cancelled before connection completes, but the
channels state are still in the SPICE_CHANNEL_STATE_UNCONNECTED state,
no events will be emitted in channel_disconnect(), and the source
session main channel will remain frozen waiting for migration completion
or failure.

Currently, for client-fd channels, the channel state remains UNCONNECTED
until the fd is provided. But if cancellation occurs, no channel events
are emitted and the source session is stuck.

Before requesting the fd, set the channel state to connecting, so it
will emit an error if disconnect happens, and it will finish cancelling
the migration in source session main channel.
---
 gtk/spice-channel.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index f59127e..3966560 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2461,10 +2461,8 @@ static gboolean channel_connect(SpiceChannel *channel)
         g_warning("%s: channel setup incomplete", __FUNCTION__);
         return false;
     }
-    if (c->state != SPICE_CHANNEL_STATE_UNCONNECTED) {
-        g_warning("Invalid channel_connect state: %d", c->state);
-        return true;
-    }
+
+    c->state = SPICE_CHANNEL_STATE_CONNECTING;
 
     if (spice_session_get_client_provided_socket(c->session)) {
         if (c->fd == -1) {
@@ -2476,7 +2474,7 @@ static gboolean channel_connect(SpiceChannel *channel)
             return true;
         }
     }
-    c->state = SPICE_CHANNEL_STATE_CONNECTING;
+
     c->xmit_queue_blocked = FALSE;
 
     g_return_val_if_fail(c->sock == NULL, FALSE);
@@ -2532,6 +2530,11 @@ gboolean spice_channel_open_fd(SpiceChannel *channel, int fd)
     g_return_val_if_fail(fd >= -1, FALSE);
 
     c = channel->priv;
+    if (c->state > SPICE_CHANNEL_STATE_CONNECTING) {
+        g_warning("Invalid channel_connect state: %d", c->state);
+        return true;
+    }
+
     c->fd = fd;
 
     return channel_connect(channel);
-- 
1.9.3



More information about the Spice-devel mailing list