[Spice-devel] [spice-gtk 1/2] Reenable call to switch_protocol() on protocol version mismatches

Christophe Fergeau cfergeau at redhat.com
Thu Oct 10 17:15:00 CEST 2013


This partially reverts b19acbc. This commit broke the fallback
to the old protocol as it added a check for c->peer_msg != NULL
before calling switch_protocol(), but mismatch between local
and remote protocol versions is detected before c->peer_msg is
allocated, so:
    if (c->peer_msg != NULL && c->link_hdr.major_version != 1) {
         SPICE_DEBUG("%s: error, switching to protocol 1 (spice 0.4)",
c->name);
         spice_channel_switch_protocol(channel, 1);
         return TRUE;
    }
will never get triggered when c->peer_hdr.major_version !=
c->link_hdr.major_version

The crash described in b19acbc occurred when calling
spice_channel_recv_link_msg() in spice_channel_coroutine()
after a call to spice_channel_recv_link_hdr() failed and did
not set c->peer_msg.

This commit removes the c>peer_msg check done before calling
spice_channel_switch_protocol() so that it gets called when needed,
but makes sure that we return FALSE to indicate that an error happened
and that we need to reconnect. This way we won't try to call
spice_channel_recv_link_msg() when c->peer_msg is NULL.
---
 gtk/spice-channel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 1ee050e..c0e7bba 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -1214,10 +1214,10 @@ error:
     /* Windows socket seems to give early CONNRESET errors. The server
        does not linger when closing the socket if the protocol is
        incompatible. Try with the oldest protocol in this case: */
-    if (c->peer_msg != NULL && c->link_hdr.major_version != 1) {
+    if (c->link_hdr.major_version != 1) {
         SPICE_DEBUG("%s: error, switching to protocol 1 (spice 0.4)", c->name);
         spice_channel_switch_protocol(channel, 1);
-        return TRUE;
+        return FALSE;
     }
 
     emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_ERROR_LINK);
-- 
1.8.3.1



More information about the Spice-devel mailing list