[Spice-devel] [PATCH v2 12/40] server/red_channel (all): makes red_channel_reset_send_data private

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


ready the way for handling ack messages in RedChannel.
---
 server/inputs_channel.c    |    1 -
 server/main_channel.c      |    1 -
 server/red_channel.c       |   49 +++++++++++++++++++++++++++++--------------
 server/red_channel.h       |    3 +-
 server/red_tunnel_worker.c |    1 -
 server/red_worker.c        |    2 -
 server/smartcard.c         |    1 -
 7 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index ce532ca..9dedc93 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -257,7 +257,6 @@ static void inputs_channel_send_item(RedChannel *channel, PipeItem *base)
     InputsChannel *inputs_channel = (InputsChannel *)channel;
     SpiceMarshaller *m = inputs_channel->base.send_data.marshaller;
 
-    red_channel_reset_send_data(channel);
     red_channel_init_send_data(channel, base->type, base);
     switch (base->type) {
         case PIPE_ITEM_KEY_MODIFIERS:
diff --git a/server/main_channel.c b/server/main_channel.c
index 64048da..ca77b98 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -591,7 +591,6 @@ static void main_channel_send_item(RedChannel *channel, PipeItem *base)
 {
     MainChannel *main_chan = SPICE_CONTAINEROF(channel, MainChannel, base);
 
-    red_channel_reset_send_data(channel);
     red_channel_init_send_data(channel, base->type, base);
     switch (base->type) {
         case SPICE_MSG_MAIN_CHANNELS_LIST:
diff --git a/server/red_channel.c b/server/red_channel.c
index 7bc1b68..4492cfb 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -241,12 +241,41 @@ static void red_channel_peer_on_out_block(void *opaque)
                                      SPICE_WATCH_EVENT_WRITE);
 }
 
+static void red_channel_reset_send_data(RedChannel *channel)
+{
+    spice_marshaller_reset(channel->send_data.marshaller);
+    channel->send_data.header = (SpiceDataHeader *)
+        spice_marshaller_reserve_space(channel->send_data.marshaller, sizeof(SpiceDataHeader));
+    spice_marshaller_set_base(channel->send_data.marshaller, sizeof(SpiceDataHeader));
+    channel->send_data.header->type = 0;
+    channel->send_data.header->size = 0;
+    channel->send_data.header->sub_list = 0;
+    channel->send_data.header->serial = ++channel->send_data.serial;
+}
+
+static void red_channel_send_item(RedChannel *channel, PipeItem *item)
+{
+    red_channel_reset_send_data(channel);
+    switch (item->type) {
+    }
+    /* only reached if not handled here */
+    channel->send_item(channel, item);
+}
+
+static void red_channel_release_item(RedChannel *channel, PipeItem *item, int item_pushed)
+{
+    switch (item->type) {
+    }
+    /* only reached if not handled here */
+    channel->release_item(channel, item, item_pushed);
+}
+
 static void red_channel_peer_on_out_msg_done(void *opaque)
 {
     RedChannel *channel = (RedChannel *)opaque;
     channel->send_data.size = 0;
     if (channel->send_data.item) {
-        channel->release_item(channel, channel->send_data.item, TRUE);
+        red_channel_release_item(channel, channel->send_data.item, TRUE);
         channel->send_data.item = NULL;
     }
     if (channel->send_data.blocked) {
@@ -447,18 +476,6 @@ void red_channel_add_buf(RedChannel *channel, void *data, uint32_t size)
     channel->send_data.header->size += size;
 }
 
-void red_channel_reset_send_data(RedChannel *channel)
-{
-    spice_marshaller_reset(channel->send_data.marshaller);
-    channel->send_data.header = (SpiceDataHeader *)
-        spice_marshaller_reserve_space(channel->send_data.marshaller, sizeof(SpiceDataHeader));
-    spice_marshaller_set_base(channel->send_data.marshaller, sizeof(SpiceDataHeader));
-    channel->send_data.header->type = 0;
-    channel->send_data.header->size = 0;
-    channel->send_data.header->sub_list = 0;
-    channel->send_data.header->serial = ++channel->send_data.serial;
-}
-
 void red_channel_init_send_data(RedChannel *channel, uint16_t msg_type, PipeItem *item)
 {
     ASSERT(channel->send_data.item == NULL);
@@ -503,7 +520,7 @@ void red_channel_push(RedChannel *channel)
     }
 
     while ((pipe_item = red_channel_pipe_get(channel))) {
-        channel->send_item(channel, pipe_item);
+        red_channel_send_item(channel, pipe_item);
     }
     channel->during_send = FALSE;
 }
@@ -609,11 +626,11 @@ void red_channel_pipe_clear(RedChannel *channel)
 
     ASSERT(channel);
     if (channel->send_data.item) {
-        channel->release_item(channel, channel->send_data.item, TRUE);
+        red_channel_release_item(channel, channel->send_data.item, TRUE);
     }
     while ((item = (PipeItem *)ring_get_head(&channel->pipe))) {
         ring_remove(&item->link);
-        channel->release_item(channel, item, FALSE);
+        red_channel_release_item(channel, item, FALSE);
     }
     channel->pipe_size = 0;
 }
diff --git a/server/red_channel.h b/server/red_channel.h
index fb5af99..9563c0e 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -203,9 +203,8 @@ int red_channel_handle_message(RedChannel *channel, uint32_t size,
 /* default error handler that disconnects channel */
 void red_channel_default_peer_on_error(RedChannel *channel);
 
-/* when preparing send_data: should call reset, then init and then add_buf per buffer that is
+/* when preparing send_data: should call init and then add_buf per buffer that is
    being sent */
-void red_channel_reset_send_data(RedChannel *channel);
 void red_channel_init_send_data(RedChannel *channel, uint16_t msg_type, PipeItem *item);
 void red_channel_add_buf(RedChannel *channel, void *data, uint32_t size);
 
diff --git a/server/red_tunnel_worker.c b/server/red_tunnel_worker.c
index 2e6a336..054a8eb 100644
--- a/server/red_tunnel_worker.c
+++ b/server/red_tunnel_worker.c
@@ -2812,7 +2812,6 @@ static void tunnel_channel_send_item(RedChannel *channel, PipeItem *item)
 {
     TunnelChannel *tunnel_channel = (TunnelChannel *)channel;
 
-    red_channel_reset_send_data(channel);
     switch (item->type) {
     case PIPE_ITEM_TYPE_SET_ACK:
         tunnel_channel_send_set_ack(tunnel_channel, item);
diff --git a/server/red_worker.c b/server/red_worker.c
index aeaaa8b..ed15eda 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -5928,7 +5928,6 @@ static void fill_cursor(CursorChannel *cursor_channel, SpiceCursor *red_cursor,
 
 static inline void red_display_reset_send_data(DisplayChannel *channel)
 {
-    red_channel_reset_send_data((RedChannel *)channel);
     red_display_reset_compress_buf(channel);
     channel->send_data.free_list.res->count = 0;
     memset(channel->send_data.free_list.sync, 0, sizeof(channel->send_data.free_list.sync));
@@ -8182,7 +8181,6 @@ static void cursor_channel_send_item(RedChannel *channel, PipeItem *pipe_item)
     CursorChannel *cursor_channel = SPICE_CONTAINEROF(channel, CursorChannel, common.base);
 
     red_ref_channel(channel);
-    red_channel_reset_send_data(channel);
     switch (pipe_item->type) {
     case PIPE_ITEM_TYPE_CURSOR:
         red_send_cursor(cursor_channel, (CursorItem *)pipe_item);
diff --git a/server/smartcard.c b/server/smartcard.c
index 6afa7cd..3675cc1 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -309,7 +309,6 @@ static void smartcard_channel_send_item(RedChannel *channel, PipeItem *item)
 {
     SmartCardChannel *smartcard_channel = (SmartCardChannel *)channel;
 
-    red_channel_reset_send_data(channel);
     switch (item->type) {
     case PIPE_ITEM_TYPE_ERROR:
         smartcard_channel_send_error(smartcard_channel, item);
-- 
1.7.4.1



More information about the Spice-devel mailing list