server/red_channel (all): makes red_channel_reset_send_data private

ready the way for handling ack messages in RedChannel.
This commit is contained in:
Alon Levy 2010-11-09 11:30:39 +02:00
parent cd99a0b4b3
commit 17b6a58f1e
7 changed files with 34 additions and 24 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);