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

Christophe Fergeau cfergeau at redhat.com
Thu Aug 31 14:11:45 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>
---
 server/cursor-channel.c |  6 +-----
 server/red-channel.c    |  1 +
 server/red-worker.c     | 12 ++----------
 3 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index 8ac5af473..2c449bdcf 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -356,11 +356,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 a8ab5230e..b9d7f533d 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -674,6 +674,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-worker.c b/server/red-worker.c
index 6ebe6b941..f819c457d 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -603,16 +603,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