MainChannel: remove another init_send_data arg

Use spice_marshaller_add_by_ref_full() instead of _add_by_ref() to
handle the referenced data properly rather than passing the pipe item to
red_channel_client_init_send_data() to keep the pipe item alive
indirectly.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Jonathon Jongsma 2016-12-20 09:59:46 -06:00 committed by Frediano Ziglio
parent 333ef51ece
commit 825880d919
3 changed files with 15 additions and 3 deletions

View File

@ -837,8 +837,10 @@ static void main_channel_marshall_agent_data(RedChannelClient *rcc,
SpiceMarshaller *m,
RedAgentDataPipeItem *item)
{
red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_AGENT_DATA, &item->base);
spice_marshaller_add_by_ref(m, item->data, item->len);
red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_AGENT_DATA, NULL);
/* since pipe item owns the data, keep it alive until it's sent */
red_pipe_item_ref(&item->base);
spice_marshaller_add_by_ref_full(m, item->data, item->len, marshaller_unref_pipe_item, item);
}
static void main_channel_marshall_migrate_data_item(RedChannelClient *rcc,
@ -846,7 +848,7 @@ static void main_channel_marshall_migrate_data_item(RedChannelClient *rcc,
RedPipeItem *item)
{
RedChannel *channel = red_channel_client_get_channel(rcc);
red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA, item);
red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA, NULL);
// TODO: from reds split. ugly separation.
reds_marshall_migrate_data(red_channel_get_server(channel), m);
}

View File

@ -46,3 +46,9 @@ void red_pipe_item_init_full(RedPipeItem *item,
item->refcount = 1;
item->free_func = free_func ? free_func : (red_pipe_item_free_t *)free;
}
void marshaller_unref_pipe_item(uint8_t *data G_GNUC_UNUSED, void *opaque)
{
RedPipeItem *item = opaque;
red_pipe_item_unref(item);
}

View File

@ -42,4 +42,8 @@ static inline void red_pipe_item_init(RedPipeItem *item, int type)
{
red_pipe_item_init_full(item, type, NULL);
}
/* a convenience function for unreffing a pipe item after it has been sent */
void marshaller_unref_pipe_item(uint8_t *data, void *opaque);
#endif