[Spice-devel] [spice-server v2 1/3] channel: Call red_channel_disconnect_if_pending_send() from red_channel_wait_all_sent()

Christophe Fergeau cfergeau at redhat.com
Tue Sep 12 14:15:02 UTC 2017


red_channel_disconnect_if_pending_send() and red_channel_wait_all_sent() are
always called together, we can remove one of the 2 methods.

Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
---
Only change since v1 is an added comment to red_channel_wait_all_sent()
to explicitly indicate it's going to disconnect slow clients.

 server/cursor-channel.c |  6 +-----
 server/red-channel.c    |  1 +
 server/red-channel.h    |  5 +++++
 server/red-worker.c     | 12 ++----------
 4 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index a844100a0..7fab4c8c7 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -305,11 +305,7 @@ void cursor_channel_reset(CursorChannel *cursor)
         if (!common_graphics_channel_get_during_target_migrate(COMMON_GRAPHICS_CHANNEL(cursor))) {
             red_channel_pipes_add_empty_msg(channel, SPICE_MSG_CURSOR_RESET);
         }
-        if (!red_channel_wait_all_sent(channel,
-                                       COMMON_CLIENT_TIMEOUT)) {
-            red_channel_apply_clients(channel,
-                                      red_channel_client_disconnect_if_pending_send);
-        }
+        red_channel_wait_all_sent(channel, COMMON_CLIENT_TIMEOUT);
     }
 }
 
diff --git a/server/red-channel.c b/server/red-channel.c
index 97be2f2bd..c24b97722 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -654,6 +654,7 @@ bool red_channel_wait_all_sent(RedChannel *channel,
     if (max_pipe_size || blocked) {
         spice_warning("timeout: pending out messages exist (pipe-size %u, blocked %d)",
                       max_pipe_size, blocked);
+        red_channel_apply_clients(channel, red_channel_client_disconnect_if_pending_send);
         return FALSE;
     } else {
         spice_assert(red_channel_no_item_being_sent(channel));
diff --git a/server/red-channel.h b/server/red-channel.h
index b5510c301..a55c830f0 100644
--- a/server/red-channel.h
+++ b/server/red-channel.h
@@ -226,6 +226,11 @@ const RedChannelCapabilities* red_channel_get_local_capabilities(RedChannel *sel
  *
  * timeout is in nano sec. -1 for no timeout.
  *
+ * This method tries for up to @timeout nanoseconds to send all the
+ * items which are currently queued. If the timeout elapses,
+ * the RedChannelClient which are too slow (those which still have pending
+ * items) will be disconnected.
+ *
  * Return: TRUE if waiting succeeded. FALSE if timeout expired.
  */
 
diff --git a/server/red-worker.c b/server/red-worker.c
index 58d9e0add..eae50dc23 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -613,16 +613,8 @@ static void handle_dev_stop(void *opaque, void *payload)
      * purge the pipe, send destroy_all_surfaces
      * to the client (there is no such message right now), and start
      * from scratch on the destination side */
-    if (!red_channel_wait_all_sent(RED_CHANNEL(worker->display_channel),
-                                   COMMON_CLIENT_TIMEOUT)) {
-        red_channel_apply_clients(RED_CHANNEL(worker->display_channel),
-                                 red_channel_client_disconnect_if_pending_send);
-    }
-    if (!red_channel_wait_all_sent(RED_CHANNEL(worker->cursor_channel),
-                                   COMMON_CLIENT_TIMEOUT)) {
-        red_channel_apply_clients(RED_CHANNEL(worker->cursor_channel),
-                                 red_channel_client_disconnect_if_pending_send);
-    }
+    red_channel_wait_all_sent(RED_CHANNEL(worker->display_channel), COMMON_CLIENT_TIMEOUT);
+    red_channel_wait_all_sent(RED_CHANNEL(worker->cursor_channel), COMMON_CLIENT_TIMEOUT);
 }
 
 static void handle_dev_start(void *opaque, void *payload)
-- 
2.13.5



More information about the Spice-devel mailing list