[spice-gtk v2 4/4] spice-channel: make _flush_wire() compatible to _read_wire()

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

 



From: Victor Toso <me@xxxxxxxxxxxxxx>

* Keeping compatibility with spice_channel_read_wire() where we keep
  the possible context switch of g_coroutine_socket_wait() in the end
  of loop and dealing with the return of the _flush_wire_nonblocking()
  case by case.

Related: https://bugs.freedesktop.org/show_bug.cgi?id=96598
Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
---
 src/spice-channel.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/spice-channel.c b/src/spice-channel.c
index 9e43c6c..55d3494 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -832,26 +832,28 @@ static void spice_channel_flush_wire(SpiceChannel *channel,
     while (offset < datalen) {
         gssize ret;
 
-        if (c->has_error) return;
+        if (c->has_error)
+            return;
 
         ret = spice_channel_flush_wire_nonblocking(channel, ptr+offset, datalen-offset, &cond);
-        if (ret == -1) {
-            if (cond != 0) {
-                // TODO: should use g_pollable_input/output_stream_create_source() in 2.28 ?
-                g_coroutine_socket_wait(&c->coroutine, c->sock, cond);
-                continue;
-            } else {
-                CHANNEL_DEBUG(channel, "Closing the channel: spice_channel_flush %d", errno);
-                c->has_error = TRUE;
-                return;
-            }
+        if (ret > 0) {
+            offset += ret;
+            continue;
         }
+
         if (ret == 0) {
             CHANNEL_DEBUG(channel, "Closing the connection: spice_channel_flush");
             c->has_error = TRUE;
             return;
         }
-        offset += ret;
+
+        if (cond == 0) {
+            CHANNEL_DEBUG(channel, "Closing the channel: spice_channel_flush %d", errno);
+            c->has_error = TRUE;
+            return;
+        }
+        // TODO: should use g_pollable_input/output_stream_create_source() in 2.28 ?
+        g_coroutine_socket_wait(&c->coroutine, c->sock, cond);
     }
 }
 
-- 
2.9.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://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]