[spice-gtk] Don't report IO error on clean guest shutdown

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 b27a672..4ca930a 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2123,11 +2123,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;
     }
 
-- 
1.9.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]