[Spice-devel] [PATCH v2 28/40] server/red_channel: add red_channel_all_blocked

Alon Levy alevy at redhat.com
Wed Mar 2 00:31:51 PST 2011


---
 server/red_channel.c |   10 ++++++++++
 server/red_channel.h |    6 ++++++
 server/red_worker.c  |   10 +++++-----
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/server/red_channel.c b/server/red_channel.c
index 22a4cc0..8476319 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -701,6 +701,16 @@ void red_channel_ack_set_client_window(RedChannel *channel, int client_window)
     channel->ack_data.client_window = client_window;
 }
 
+int red_channel_all_blocked(RedChannel *channel)
+{
+    return channel->send_data.blocked;
+}
+
+int red_channel_any_blocked(RedChannel *channel)
+{
+    return channel->send_data.blocked;
+}
+
 /* accessors for RedChannel */
 SpiceMarshaller *red_channel_get_marshaller(RedChannel *channel)
 {
diff --git a/server/red_channel.h b/server/red_channel.h
index 61aa788..96b6095 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -251,6 +251,12 @@ void red_channel_shutdown(RedChannel *channel);
 
 int red_channel_get_first_socket(RedChannel *channel);
 
+/* return TRUE if all of the connected clients to this channel are blocked */
+int red_channel_all_blocked(RedChannel *channel);
+
+/* return TRUE if any of the connected clients to this channel are blocked */
+int red_channel_any_blocked(RedChannel *channel);
+
 // TODO: unstaticed for display/cursor channels. they do some specific pushes not through
 // adding elements or on events. but not sure if this is actually required (only result
 // should be that they ""try"" a little harder, but if the event system is correct it
diff --git a/server/red_worker.c b/server/red_worker.c
index fd83f2d..e0894d9 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -4289,7 +4289,7 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
             red_error("bad command type");
         }
         n++;
-        if ((worker->display_channel && worker->display_channel->common.base.send_data.blocked) ||
+        if ((worker->display_channel && red_channel_all_blocked(&worker->display_channel->common.base)) ||
             red_now() - start > 10 * 1000 * 1000) {
             worker->epoll_timeout = 0;
             return n;
@@ -9133,7 +9133,7 @@ static void handle_channel_events(EventListener *in_listener, uint32_t events)
         red_channel_receive(channel);
     }
 
-    if (channel->send_data.blocked) {
+    if (red_channel_any_blocked(channel)) {
         red_channel_send(channel);
     }
 }
@@ -9410,7 +9410,7 @@ static void red_wait_outgoing_item(RedChannel *channel)
     uint64_t end_time;
     int blocked;
 
-    if (!channel || !channel->send_data.blocked) {
+    if (!channel || !red_channel_all_blocked(channel)) {
         return;
     }
     red_ref_channel(channel);
@@ -9422,7 +9422,7 @@ static void red_wait_outgoing_item(RedChannel *channel)
         usleep(DETACH_SLEEP_DURATION);
         red_channel_receive(channel);
         red_channel_send(channel);
-    } while ((blocked = channel->send_data.blocked) && red_now() < end_time);
+    } while ((blocked = red_channel_all_blocked(channel)) && red_now() < end_time);
 
     if (blocked) {
         red_printf("timeout");
@@ -9448,7 +9448,7 @@ static void red_wait_pipe_item_sent(RedChannel *channel, PipeItem *item)
 
     end_time = red_now() + CHANNEL_PUSH_TIMEOUT;
 
-    if (channel->send_data.blocked) {
+    if (red_channel_all_blocked(channel)) {
         red_channel_receive(channel);
         red_channel_send(channel);
     }
-- 
1.7.4.1



More information about the Spice-devel mailing list