[Spice-commits] 2 commits - server/red-channel-client.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 2 10:28:16 UTC 2019


 server/red-channel-client.c |   43 +++++++++++++++++++++----------------------
 1 file changed, 21 insertions(+), 22 deletions(-)

New commits:
commit cee05ca8ac7ce26613667cfc584e046fd1abc876
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed May 22 05:10:23 2019 +0100

    red-channel-client: Add some comment on the flush code
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>,

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 3fd51d78..337733d5 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1319,6 +1319,9 @@ void red_channel_client_push(RedChannelClient *rcc)
     /* prepare_pipe_add() will reenable WRITE events when the rcc->priv->pipe is empty
      * red_channel_client_ack_zero_messages_window() will reenable WRITE events
      * if we were waiting for acks to be received
+     * If we don't remove WRITE if we are waiting for ack we will be keep
+     * notified that we can write and we then exit (see pipe_item_get) as we
+     * are waiting for the ack consuming CPU in a tight loop
      */
     if ((red_channel_client_no_item_being_sent(rcc) && g_queue_is_empty(&rcc->priv->pipe)) ||
         red_channel_client_waiting_for_ack(rcc)) {
@@ -1326,6 +1329,9 @@ void red_channel_client_push(RedChannelClient *rcc)
         /* channel has no pending data to send so now we can flush data in
          * order to avoid data stall into buffers in case of manual
          * flushing
+         * We need to flush also in case of ack as it is possible
+         * that for a long train of small messages the message that would
+         * cause the client to send the ack is still in the queue
          */
         red_stream_flush(rcc->priv->stream);
     }
commit 2e357a9b7b2667d00baf3f792c60ef511b5d8095
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed May 22 05:10:33 2019 +0100

    red-channel-client: Reduce indentation of some code
    
    Just a style change, return earlier to avoid some indentation.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 4978f356..3fd51d78 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -690,25 +690,21 @@ static void red_channel_client_ping_timer(void *opaque)
     red_channel_client_cancel_ping_timer(rcc);
 
 #ifdef HAVE_LINUX_SOCKIOS_H /* SIOCOUTQ is a Linux only ioctl on sockets. */
-    {
-        int so_unsent_size = 0;
+    int so_unsent_size = 0;
 
-        /* retrieving the occupied size of the socket's tcp snd buffer (unacked + unsent) */
-        if (ioctl(rcc->priv->stream->socket, SIOCOUTQ, &so_unsent_size) == -1) {
-            red_channel_warning(red_channel_client_get_channel(rcc),
-                                "ioctl(SIOCOUTQ) failed, %s", strerror(errno));
-        }
-        if (so_unsent_size > 0) {
-            /* tcp snd buffer is still occupied. rescheduling ping */
-            red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS);
-        } else {
-            red_channel_client_push_ping(rcc);
-        }
+    /* retrieving the occupied size of the socket's tcp snd buffer (unacked + unsent) */
+    if (ioctl(rcc->priv->stream->socket, SIOCOUTQ, &so_unsent_size) == -1) {
+        red_channel_warning(red_channel_client_get_channel(rcc),
+                            "ioctl(SIOCOUTQ) failed, %s", strerror(errno));
     }
-#else /* ifdef HAVE_LINUX_SOCKIOS_H */
+    if (so_unsent_size > 0) {
+        /* tcp snd buffer is still occupied. rescheduling ping */
+        red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS);
+        return;
+    }
+#endif /* ifdef HAVE_LINUX_SOCKIOS_H */
     /* More portable alternative code path (less accurate but avoids bogus ioctls)*/
     red_channel_client_push_ping(rcc);
-#endif /* ifdef HAVE_LINUX_SOCKIOS_H */
 }
 
 static inline int red_channel_client_waiting_for_ack(RedChannelClient *rcc)
@@ -1140,16 +1136,13 @@ static int red_peer_receive(RedStream *stream, uint8_t *buf, uint32_t size)
                 break;
             } else if (errno == EINTR) {
                 continue;
-            } else if (errno == EPIPE) {
-                return -1;
-            } else {
+            } else if (errno != EPIPE) {
                 g_warning("%s", strerror(errno));
-                return -1;
             }
-        } else {
-            size -= now;
-            pos += now;
+            return -1;
         }
+        size -= now;
+        pos += now;
     }
     return pos - buf;
 }


More information about the Spice-commits mailing list