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

Frediano Ziglio fziglio at kemper.freedesktop.org
Wed Nov 29 17:00:59 UTC 2017


 server/red-channel-client.c |   19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

New commits:
commit 8e06a576492963176e63fff9f5fb5e12c9beabfe
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Sep 11 10:20:48 2017 +0100

    red-channel-client: Simplify red_channel_client_wait_pipe_item_sent
    
    Currently, red_channel_client_wait_pipe_item_sent() inserts a MarkerItem
    which will sent after the item we want to wait for: the tail of the
    queue is the first item to send, and the function uses
    red_channel_client_pipe_add_after_pos(). Then, if the marker has been
    successfully sent, the function calls
    red_channel_client_wait_outgoing_item to wait for 'item' to be sent.
    
    Instead of doing this, we can add the MarkerItem to the queue so that
    it's sent after 'item' (ie, insert it _before_ 'item' in the queue).
    This way, when the marker is marked as having been sent, we'll also know
    that 'item' has been sent.
    
    This avoids having to call red_channel_client_wait_outgoing_item and
    possibly the case where the item was not queued and
    red_channel_client_wait_outgoing_item returning TRUE even if the item
    was not sent as required.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 086c5fa4..f9f7186e 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1574,6 +1574,19 @@ void red_channel_client_pipe_add_after_pos(RedChannelClient *rcc,
     g_queue_insert_after(&rcc->priv->pipe, pipe_item_pos, item);
 }
 
+static void
+red_channel_client_pipe_add_before_pos(RedChannelClient *rcc,
+                                       RedPipeItem *item,
+                                       GList *pipe_item_pos)
+{
+    spice_assert(pipe_item_pos);
+    if (!prepare_pipe_add(rcc, item)) {
+        return;
+    }
+
+    g_queue_insert_before(&rcc->priv->pipe, pipe_item_pos, item);
+}
+
 void red_channel_client_pipe_add_after(RedChannelClient *rcc,
                                        RedPipeItem *item,
                                        RedPipeItem *pos)
@@ -1774,7 +1787,7 @@ bool red_channel_client_wait_pipe_item_sent(RedChannelClient *rcc,
     red_pipe_item_init(&mark_item->base, RED_PIPE_ITEM_TYPE_MARKER);
     mark_item->item_in_pipe = true;
     red_pipe_item_ref(&mark_item->base);
-    red_channel_client_pipe_add_after_pos(rcc, &mark_item->base, item_pos);
+    red_channel_client_pipe_add_before_pos(rcc, &mark_item->base, item_pos);
 
     for (;;) {
         red_channel_client_receive(rcc);
@@ -1793,10 +1806,8 @@ bool red_channel_client_wait_pipe_item_sent(RedChannelClient *rcc,
         // still on the queue
         spice_warning("timeout");
         return FALSE;
-    } else {
-        return red_channel_client_wait_outgoing_item(rcc,
-                                                     timeout == -1 ? -1 : end_time - spice_get_monotonic_time_ns());
     }
+    return TRUE;
 }
 
 bool red_channel_client_wait_outgoing_item(RedChannelClient *rcc,


More information about the Spice-commits mailing list