From 17b6a58f1eb27f5042a02eb690e127ee58987c25 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Tue, 9 Nov 2010 11:30:39 +0200 Subject: server/red_channel (all): makes red_channel_reset_send_data private 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(-) (limited to 'server') diff --git a/server/inputs_channel.c b/server/inputs_channel.c index ce532caf..9dedc930 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 64048daa..ca77b98f 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 7bc1b688..4492cfb5 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 fb5af99c..9563c0e2 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 2e6a336d..054a8eb6 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 aeaaa8b1..ed15eda0 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 6afa7cd2..3675cc1a 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); -- cgit