[Spice-devel] [PATCH spice-gtk 01/13] migration: add a few more pre-conditions in migration code

Marc-André Lureau marcandre.lureau at redhat.com
Sun Nov 9 08:31:33 PST 2014


Those preconditions help to figure out several issues related to
migration.
---
 gtk/channel-main.c  | 2 ++
 gtk/spice-channel.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 1ad090f..62e8905 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -2074,6 +2074,8 @@ static gboolean migrate_connect(gpointer data)
     g_return_val_if_fail(c != NULL, FALSE);
 
     session = spice_channel_get_session(mig->src_channel);
+    g_return_val_if_fail(session->priv->migration == NULL, FALSE);
+
     mig->session = spice_session_new_from_session(session);
     mig->session->priv->migration_copy = true;
 
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 6c24bf5..ed18e09 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2495,6 +2495,7 @@ static gboolean channel_connect(SpiceChannel *channel)
 gboolean spice_channel_connect(SpiceChannel *channel)
 {
     g_return_val_if_fail(SPICE_IS_CHANNEL(channel), FALSE);
+    g_return_val_if_fail(channel->priv->fd == -1, FALSE);
     SpiceChannelPrivate *c = channel->priv;
 
     if (c->state >= SPICE_CHANNEL_STATE_CONNECTING)
@@ -2522,6 +2523,7 @@ gboolean spice_channel_open_fd(SpiceChannel *channel, int fd)
 
     g_return_val_if_fail(SPICE_IS_CHANNEL(channel), FALSE);
     g_return_val_if_fail(channel->priv != NULL, FALSE);
+    g_return_val_if_fail(channel->priv->fd == -1, FALSE);
     g_return_val_if_fail(fd >= -1, FALSE);
 
     c = channel->priv;
-- 
1.9.3



More information about the Spice-devel mailing list