[Spice-devel] [PATCH spice-gtk 2/2] Fix semi-seamless migration handling

Marc-André Lureau marcandre.lureau at gmail.com
Mon Mar 5 09:01:52 PST 2012


SPICE_MSGC_MAIN_MIGRATE_END was dropped because the main channel was
xmit_queue_blocked. When we swap the channels, we should also swap
xmit_queue.
---
 gtk/spice-channel.c |   61 ++++++++++++++++-----------------------------------
 1 files changed, 19 insertions(+), 42 deletions(-)

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index d0a287b..ae38ef8 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2578,49 +2578,26 @@ void spice_channel_swap(SpiceChannel *channel, SpiceChannel *swap)
     g_return_if_fail(s->session != NULL);
     g_return_if_fail(s->sock != NULL);
 
-    {
-        GSocket *sock = c->sock;
-        SSL_CTX *ctx = c->ctx;
-        SSL *ssl = c->ssl;
-        SpiceOpenSSLVerify *sslverify = c->sslverify;
-        uint64_t in_serial = c->in_serial;
-        uint64_t out_serial = c->out_serial;
-        gboolean use_mini_header = c->use_mini_header;
-
-        c->sock = s->sock;
-        c->ctx = s->ctx;
-        c->ssl = s->ssl;
-        c->sslverify = s->sslverify;
-        c->in_serial = s->in_serial;
-        c->out_serial = s->out_serial;
-        c->use_mini_header = s->use_mini_header;
-
-        s->sock = sock;
-        s->ctx = ctx;
-        s->ssl = ssl;
-        s->sslverify = sslverify;
-        s->in_serial = in_serial;
-        s->out_serial = out_serial;
-        s->use_mini_header = use_mini_header;
-    }
-
+#define SWAP(Field) ({                          \
+    __typeof__ (c->Field) Field = c->Field;     \
+    c->Field = s->Field;                        \
+    s->Field = Field;                           \
+})
+
+    SWAP(sock);
+    SWAP(ctx);
+    SWAP(ssl);
+    SWAP(sslverify);
+    SWAP(in_serial);
+    SWAP(out_serial);
+    SWAP(use_mini_header);
+    SWAP(xmit_queue);
+    SWAP(xmit_queue_blocked);
 #if HAVE_SASL
-    {
-        sasl_conn_t *sasl_conn = c->sasl_conn;
-        const char *sasl_decoded = c->sasl_decoded;
-        unsigned int sasl_decoded_length = c->sasl_decoded_length;
-        unsigned int sasl_decoded_offset = c->sasl_decoded_offset;
-
-        c->sasl_conn = s->sasl_conn;
-        c->sasl_decoded = s->sasl_decoded;
-        c->sasl_decoded_length = s->sasl_decoded_length;
-        c->sasl_decoded_offset = s->sasl_decoded_offset;
-
-        s->sasl_conn = sasl_conn;
-        s->sasl_decoded = sasl_decoded;
-        s->sasl_decoded_length = sasl_decoded_length;
-        s->sasl_decoded_offset = sasl_decoded_offset;
-    }
+    SWAP(sasl_conn);
+    SWAP(sasl_decoded);
+    SWAP(sasl_decoded_length);
+    SWAP(sasl_decoded_offset);
 #endif
 }
 
-- 
1.7.7.6



More information about the Spice-devel mailing list