summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2014-09-10 15:50:53 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2014-09-18 13:22:10 +0200
commit9cd267a9db91aee10459a4a2bbb984663b03dd9e (patch)
treec61e3390e1b31b35dae9a74af7246f08077dff83
parent457d556c00c59bdb44476d1154b876652788d05f (diff)
Don't report IO error on clean guest shutdown
Since commit 9cf9ca434, spice_channel_iterate() will report a SPICE_CHANNEL_ERROR_IO error to library users when SpiceChannel::has_error is set. In particular, when the server side closes its SPICE sockets because the VM is being shut down, an IO error will get reported. Prior to this change, a channel-closed event was reported on graceful VM shutdowns as there was a g_socket_condition_check() guarding the emission of the IO error signal. This commit readds the g_socket_condition_check() test, but only when SpiceChannel::has_error is set. This fixes https://bugs.freedesktop.org/show_bug.cgi?id=83692
-rw-r--r--gtk/spice-channel.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index e875963..5d1a86e 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2117,11 +2117,18 @@ static gboolean spice_channel_iterate(SpiceChannel *channel)
SPICE_CHANNEL_GET_CLASS(channel)->iterate_read(channel);
if (c->has_error) {
- CHANNEL_DEBUG(channel, "channel got error");
- if (c->state > SPICE_CHANNEL_STATE_CONNECTING)
- g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0,
- c->state == SPICE_CHANNEL_STATE_READY ?
- SPICE_CHANNEL_ERROR_IO : SPICE_CHANNEL_ERROR_LINK);
+ GIOCondition ret;
+ /* We don't want to report an error if the socket was closed gracefully
+ * on the other end (VM shutdown) */
+ ret = g_socket_condition_check(c->sock, G_IO_IN | G_IO_ERR | G_IO_HUP);
+ if (ret & (G_IO_ERR|G_IO_HUP)) {
+ CHANNEL_DEBUG(channel, "channel got error");
+ if (c->state > SPICE_CHANNEL_STATE_CONNECTING) {
+ g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0,
+ c->state == SPICE_CHANNEL_STATE_READY ?
+ SPICE_CHANNEL_ERROR_IO : SPICE_CHANNEL_ERROR_LINK);
+ }
+ }
return FALSE;
}