[spice-gtk 10/13] channel: simplify has error code

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

 



From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

Get rid of a superflous g_socket_condition_check().
---
 gtk/spice-channel.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 7459a49..87bc471 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2105,29 +2105,23 @@ static gboolean wait_migration(gpointer data)
 static gboolean spice_channel_iterate(SpiceChannel *channel)
 {
     SpiceChannelPrivate *c = channel->priv;
-    GIOCondition ret;
 
     if (c->state == SPICE_CHANNEL_STATE_MIGRATING &&
         !g_coroutine_condition_wait(&c->coroutine, wait_migration, channel))
         CHANNEL_DEBUG(channel, "migration wait cancelled");
 
-    if (c->has_error) {
-        CHANNEL_DEBUG(channel, "channel has error, breaking loop");
-        return FALSE;
-    }
-
     /* flush any pending write and read */
-    SPICE_CHANNEL_GET_CLASS(channel)->iterate_write(channel);
-    SPICE_CHANNEL_GET_CLASS(channel)->iterate_read(channel);
-
-    ret = g_socket_condition_check(c->sock, G_IO_IN | G_IO_ERR | G_IO_HUP);
-    if (c->state > SPICE_CHANNEL_STATE_CONNECTING &&
-        ret & (G_IO_ERR|G_IO_HUP)) {
-        SPICE_DEBUG("got socket error: %d", ret);
-        emit_main_context(channel, SPICE_CHANNEL_EVENT,
-                          c->state == SPICE_CHANNEL_STATE_READY ?
-                          SPICE_CHANNEL_ERROR_IO : SPICE_CHANNEL_ERROR_LINK);
-        c->has_error = TRUE;
+    if (!c->has_error)
+        SPICE_CHANNEL_GET_CLASS(channel)->iterate_write(channel);
+    if (!c->has_error)
+        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)
+            emit_main_context(channel, SPICE_CHANNEL_EVENT,
+                              c->state == SPICE_CHANNEL_STATE_READY ?
+                              SPICE_CHANNEL_ERROR_IO : SPICE_CHANNEL_ERROR_LINK);
         return FALSE;
     }
 
-- 
1.8.4.2

_______________________________________________
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]