From 9cd267a9db91aee10459a4a2bbb984663b03dd9e Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Wed, 10 Sep 2014 15:50:53 +0200 Subject: 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 --- gtk/spice-channel.c | 17 ++++++++++++----- 1 file 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; } -- cgit v1.2.3