[Spice-devel,spice-gtk,v2,1/5] Fix not setting channel specific capabilities upon channel reset

Submitted by Yonit Halperin on May 17, 2012, 12:25 p.m.

Details

Message ID 1337257538-8426-2-git-send-email-yhalperi@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Yonit Halperin May 17, 2012, 12:25 p.m.
Related: rhbz#821795

The capabilities have been zeroed after channel reset, which have lead to
publish the wrong caps when both port and tls-port are given, and the
channels are secured (first attempt to connect the channel with "port"
has failed; the channel got reset, and then reconnected with "tls-port"
and bad caps). Specifically, the bug causes semi-seamless migration not
to work when part of the channels are secured.
---
 gtk/spice-channel.c |   20 ++++++++++++++++++--
 gtk/spice-channel.h |    1 +
 2 files changed, 19 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 574867c..5cef1d2 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -48,6 +48,7 @@  static void spice_channel_write_msg(SpiceChannel *channel, SpiceMsgOut *out);
 static void spice_channel_send_link(SpiceChannel *channel);
 static void channel_disconnect(SpiceChannel *channel);
 static void channel_reset(SpiceChannel *channel, gboolean migrating);
+static void spice_channel_reset_capabilities(SpiceChannel *channel);
 
 /**
  * SECTION:spice-channel
@@ -1147,7 +1148,11 @@  static void spice_channel_send_link(SpiceChannel *channel)
         *(uint32_t *)p = g_array_index(c->caps, uint32_t, i);
         p += sizeof(uint32_t);
     }
-
+    SPICE_DEBUG("channel type %d id %d num common caps %d num caps %d",
+                c->link_msg.channel_type,
+                c->link_msg.channel_id,
+                c->link_msg.num_common_caps,
+                c->link_msg.num_channel_caps);
     spice_channel_write(channel, buffer, p - buffer);
     free(buffer);
 }
@@ -2390,10 +2395,10 @@  static void channel_reset(SpiceChannel *channel, gboolean migrating)
     g_array_set_size(c->remote_common_caps, 0);
     g_array_set_size(c->remote_caps, 0);
     g_array_set_size(c->common_caps, 0);
-    g_array_set_size(c->caps, 0);
     /* Restore our default capabilities in case the channel gets re-used */
     spice_channel_set_common_capability(channel, SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
     spice_channel_set_common_capability(channel, SPICE_COMMON_CAP_MINI_HEADER);
+    spice_channel_reset_capabilities(channel);
 }
 
 /* system or coroutine context */
@@ -2632,3 +2637,14 @@  static void spice_channel_handle_msg(SpiceChannel *channel, SpiceMsgIn *msg)
 
     base_handlers[type](channel, msg);
 }
+
+static void spice_channel_reset_capabilities(SpiceChannel *channel)
+{
+
+    SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
+    g_array_set_size(c->caps, 0);
+
+    if (SPICE_CHANNEL_GET_CLASS(channel)->channel_reset_capabilities) {
+        SPICE_CHANNEL_GET_CLASS(channel)->channel_reset_capabilities(channel);
+    }
+}
diff --git a/gtk/spice-channel.h b/gtk/spice-channel.h
index 2a8e7e7..f722c99 100644
--- a/gtk/spice-channel.h
+++ b/gtk/spice-channel.h
@@ -78,6 +78,7 @@  struct _SpiceChannelClass
     void (*channel_up)(SpiceChannel *channel);
     void (*iterate_write)(SpiceChannel *channel);
     void (*iterate_read)(SpiceChannel *channel);
+    void (*channel_reset_capabilities)(SpiceChannel *channel);
 
     /*< public >*/
     /* signals, main context */

Comments

On Thu, May 17, 2012 at 2:25 PM, Yonit Halperin <yhalperi@redhat.com> wrote:
> +static void spice_channel_reset_capabilities(SpiceChannel *channel)
> +{
> +

there is an extra line here

> +    SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
> +    g_array_set_size(c->caps, 0);
> +
> +    if (SPICE_CHANNEL_GET_CLASS(channel)->channel_reset_capabilities) {
> +        SPICE_CHANNEL_GET_CLASS(channel)->channel_reset_capabilities(channel);
> +    }

ack series