diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2011-01-07 21:48:59 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2011-01-07 22:37:26 +0100 |
commit | 27d786f2265946c86da4575bc4680a428600efb8 (patch) | |
tree | 4924450de0e7801e19c44b22c5a3adf9b4cf5600 | |
parent | bff13f1574ed18a7669f0d9f5c2e9fd99678ea99 (diff) |
gtk: emit ERROR_LINK when connecting to non-spice server
-rw-r--r-- | gtk/spice-channel.c | 17 | ||||
-rw-r--r-- | gtk/spicy.c | 4 |
2 files changed, 17 insertions, 4 deletions
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c index c329e29..4647a4c 100644 --- a/gtk/spice-channel.c +++ b/gtk/spice-channel.c @@ -740,6 +740,7 @@ static void spice_channel_recv_auth(SpiceChannel *channel) if (rc != sizeof(link_res)) { g_critical("incomplete auth reply (%d/%" G_GSIZE_FORMAT ")", rc, sizeof(link_res)); + emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_ERROR_LINK); return; } @@ -823,9 +824,12 @@ static void spice_channel_recv_link_hdr(SpiceChannel *channel) if (rc != sizeof(c->peer_hdr)) { g_critical("incomplete link header (%d/%" G_GSIZE_FORMAT ")", rc, sizeof(c->peer_hdr)); - return; + goto error; + } + if (c->peer_hdr.magic != SPICE_MAGIC) { + g_critical("invalid SPICE_MAGIC!"); + goto error; } - g_return_if_fail(c->peer_hdr.magic == SPICE_MAGIC); if (c->peer_hdr.major_version != c->link_hdr.major_version) { if (c->peer_hdr.major_version == 1) { @@ -838,11 +842,15 @@ static void spice_channel_recv_link_hdr(SpiceChannel *channel) } g_critical("major mismatch (got %d, expected %d)", c->peer_hdr.major_version, c->link_hdr.major_version); - return; + goto error; } c->peer_msg = spice_malloc(c->peer_hdr.size); c->state = SPICE_CHANNEL_STATE_LINK_MSG; + return; + +error: + emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_ERROR_LINK); } /* coroutine context */ @@ -857,8 +865,9 @@ static void spice_channel_recv_link_msg(SpiceChannel *channel) c->peer_hdr.size - c->peer_pos); c->peer_pos += rc; if (c->peer_pos != c->peer_hdr.size) { - g_warning("%s: %s: incomplete link reply (%d/%d)", + g_critical("%s: %s: incomplete link reply (%d/%d)", c->name, __FUNCTION__, rc, c->peer_hdr.size); + emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_ERROR_LINK); return; } switch (c->peer_msg->error) { diff --git a/gtk/spicy.c b/gtk/spicy.c index 517439e..a8ac009 100644 --- a/gtk/spicy.c +++ b/gtk/spicy.c @@ -734,6 +734,10 @@ static void main_channel_event(SpiceChannel *channel, SpiceChannelEvent event, g_message("main channel: closed"); connection_disconnect(conn); break; + case SPICE_CHANNEL_ERROR_IO: + connection_disconnect(conn); + break; + case SPICE_CHANNEL_ERROR_LINK: case SPICE_CHANNEL_ERROR_CONNECT: g_message("main channel: failed to connect"); rc = connect_dialog(NULL, conn->session); |