---
 server/red_channel.c |   15 +++++++++++++--
 server/red_channel.h |    8 ++++++++
 server/red_worker.c  |   10 +++++-----
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/server/red_channel.c b/server/red_channel.c
index f2665a4..8eb4e0d 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -727,6 +727,12 @@ RedsStream *red_channel_get_stream(RedChannel *channel)
     return channel->stream;
 }
 
+SpiceDataHeader *red_channel_get_header(RedChannel *channel)
+{
+    return channel->send_data.header;
+}
+/* end of accessors */
+
 int red_channel_get_first_socket(RedChannel *channel)
 {
     if (!channel->stream) {
@@ -735,7 +741,12 @@ int red_channel_get_first_socket(RedChannel *channel)
     return channel->stream->socket;
 }
 
-SpiceDataHeader *red_channel_get_header(RedChannel *channel)
+int red_channel_item_being_sent(RedChannel *channel, PipeItem *item)
 {
-    return channel->send_data.header;
+    return channel->send_data.item == item;
+}
+
+int red_channel_no_item_being_sent(RedChannel *channel)
+{
+    return channel->send_data.item == NULL;
 }
diff --git a/server/red_channel.h b/server/red_channel.h
index ce8ef20..d08b661 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -260,6 +260,14 @@ int red_channel_any_blocked(RedChannel *channel);
 /* helper for channels that have complex logic that can possibly ready a send 
*/
 int red_channel_send_message_pending(RedChannel *channel);
 
+/* returns TRUE if item is being sent by one of the channel clients. This will
+ * be true if someone called init_send_data but send has not completed (or 
perhaps
+ * hasn't even begun, i.e. no one called begin_send_)
+ * */
+int red_channel_item_being_sent(RedChannel *channel, PipeItem *item);
+
+int red_channel_no_item_being_sent(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 357ddee..b5bb3b3 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -9436,7 +9436,7 @@ static void red_wait_pipe_item_sent(RedChannel *channel, 
PipeItem *item)
         red_printf("timeout");
         channel->disconnect(channel);
     } else {
-        if (channel->send_data.item == item) {
+        if (red_channel_item_being_sent(channel, item)) {
             red_wait_outgoing_item(channel);
         }
     }
@@ -9522,7 +9522,7 @@ static inline void destroy_surface_wait(RedWorker 
*worker, int surface_id)
     // there is one during sending.
     red_wait_outgoing_item((RedChannel *)worker->display_channel);
     if (worker->display_channel) {
-        ASSERT(!worker->display_channel->common.base.send_data.item);
+        
ASSERT(red_channel_no_item_being_sent(&worker->display_channel->common.base));
     }
 }
 
@@ -9570,7 +9570,7 @@ static inline void handle_dev_destroy_surfaces(RedWorker 
*worker)
         if (!worker->cursor_channel->common.base.migrate) {
             red_pipe_add_verb(&worker->cursor_channel->common.base, 
SPICE_MSG_CURSOR_RESET);
         }
-        ASSERT(!worker->cursor_channel->common.base.send_data.item);
+        
ASSERT(red_channel_no_item_being_sent(&worker->cursor_channel->common.base));
     }
 
     if (worker->display_channel) {
@@ -9646,7 +9646,7 @@ static inline void 
handle_dev_destroy_primary_surface(RedWorker *worker)
         if (!worker->cursor_channel->common.base.migrate) {
             red_pipe_add_verb(&worker->cursor_channel->common.base, 
SPICE_MSG_CURSOR_RESET);
         }
-        ASSERT(!worker->cursor_channel->common.base.send_data.item);
+        
ASSERT(red_channel_no_item_being_sent(&worker->cursor_channel->common.base));
     }
 
     flush_all_qxl_commands(worker);
@@ -9708,7 +9708,7 @@ static void handle_dev_input(EventListener *listener, 
uint32_t events)
             if (!cursor_red_channel->migrate) {
                 red_pipe_add_verb(cursor_red_channel, SPICE_MSG_CURSOR_RESET);
             }
-            ASSERT(!cursor_red_channel->send_data.item);
+            ASSERT(red_channel_no_item_being_sent(cursor_red_channel));
 
             worker->cursor_visible = TRUE;
             worker->cursor_position.x = worker->cursor_position.y = 0;
-- 
1.7.4.1

_______________________________________________
Spice-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to