[Spice-devel] [RFC v4 07/62] server/main_channel: use MainChannel in sig
Marc-André Lureau
marcandre.lureau at gmail.com
Mon May 2 16:53:20 PDT 2011
We have these various channel types for main_channel_foo()
argument/return value, would be nice to make some changes:
- Channel *main_channel_init()
reds->main_channel_factory = main_channel_init();
Should we rename main_channel_init() to main_channel_factory_new()?
and perhaps rename Channel to ChannelFactory?
- RedChannelClient *main_channel_link(struct Channel *,..)
rcc = main_channel_link(reds->main_channel_factory,..)
reds->main_channel = (MainChannel*)rcc->channel;
I think we could have this instead (correct prefix, return proper
type, better naming):
reds->main_channel = main_channel_factory_build();
- void main_channel_close(MainChannel *main_chan);
this one is good!
- void main_channel_push_init(RedChannelClient *rcc,...)
Wouldn't it be more sensible if the main_channel_foo() with
RedChannelClient* take a MainChannel* instead?
But this seems to be fixed in a later patch
On Tue, Apr 26, 2011 at 12:54 PM, Alon Levy <alevy at redhat.com> wrote:
> use MainChannel* instead of Channel* for a many functions in main_channel.h
> (affects main_channel.c and reds.c).
>
> some one liner fixes are hidden in here too.
> ---
> server/main_channel.c | 124 ++++++++++++++++++++----------------------------
> server/main_channel.h | 42 +++++++++-------
> server/red_channel.c | 4 +-
> server/reds.c | 21 ++++++---
> 4 files changed, 92 insertions(+), 99 deletions(-)
>
> diff --git a/server/main_channel.c b/server/main_channel.c
> index 749acbf..5b175de 100644
> --- a/server/main_channel.c
> +++ b/server/main_channel.c
> @@ -114,13 +114,17 @@ typedef struct MultiMediaTimePipeItem {
> int time;
> } MultiMediaTimePipeItem;
>
> -typedef struct MainChannel {
> - RedChannel base;
> - uint8_t recv_buf[RECEIVE_BUF_SIZE];
> +typedef struct MainChannelClient {
> + RedChannelClient base;
> uint32_t ping_id;
> uint32_t net_test_id;
> int net_test_stage;
> -} MainChannel;
> +} MainChannelClient;
> +
> +struct MainChannel {
> + RedChannel base;
> + uint8_t recv_buf[RECEIVE_BUF_SIZE];
> +};
>
> enum NetTestStage {
> NET_TEST_STAGE_INVALID = 0,
> @@ -134,9 +138,6 @@ uint64_t bitrate_per_sec = ~0;
>
> static void main_disconnect(MainChannel *main_chan)
> {
> - main_chan->ping_id = 0;
> - main_chan->net_test_id = 0;
> - main_chan->net_test_stage = NET_TEST_STAGE_INVALID;
> red_channel_destroy(&main_chan->base);
>
> latency = 0;
> @@ -145,21 +146,18 @@ static void main_disconnect(MainChannel *main_chan)
>
> static int main_channel_client_push_ping(RedChannelClient *rcc, int size);
>
> -void main_channel_start_net_test(Channel *channel)
> +void main_channel_start_net_test(RedChannelClient *rcc)
> {
> - MainChannel *main_chan = channel->data;
> - RedChannelClient *rcc;
> + MainChannelClient *mcc = SPICE_CONTAINEROF(rcc, MainChannelClient, base);
>
> - if (!main_chan || !main_chan->base.rcc || main_chan->net_test_id) {
> + if (!rcc) {
> return;
> }
> - rcc = main_chan->base.rcc;
> -
> if (main_channel_client_push_ping(rcc, NET_TEST_WARMUP_BYTES)
> && main_channel_client_push_ping(rcc, 0)
> && main_channel_client_push_ping(rcc, NET_TEST_BYTES)) {
> - main_chan->net_test_id = main_chan->ping_id - 2;
> - main_chan->net_test_stage = NET_TEST_STAGE_WARMUP;
> + mcc->net_test_id = mcc->ping_id - 2;
> + mcc->net_test_stage = NET_TEST_STAGE_WARMUP;
> }
> }
>
> @@ -304,10 +302,8 @@ int main_channel_client_push_ping(RedChannelClient *rcc, int size)
> return TRUE;
> }
>
> -int main_channel_push_ping(Channel *channel, int size)
> +int main_channel_push_ping(MainChannel *main_chan, int size)
> {
> - MainChannel *main_chan = channel->data;
> -
> if (main_chan->base.rcc == NULL) {
> return FALSE;
> }
> @@ -334,11 +330,9 @@ static void main_channel_marshall_ping(SpiceMarshaller *m, int size, int ping_id
> static void main_channel_client_push_mouse_mode(RedChannelClient *rcc, int current_mode,
> int is_client_mouse_allowed);
>
> -void main_channel_push_mouse_mode(Channel *channel, int current_mode,
> +void main_channel_push_mouse_mode(MainChannel *main_chan, int current_mode,
> int is_client_mouse_allowed)
> {
> - MainChannel *main_chan = channel->data;
> -
> if (main_chan && main_chan->base.rcc != NULL) {
> main_channel_client_push_mouse_mode(main_chan->base.rcc, current_mode,
> is_client_mouse_allowed);
> @@ -366,19 +360,18 @@ static void main_channel_marshall_mouse_mode(SpiceMarshaller *m, int current_mod
> spice_marshall_msg_main_mouse_mode(m, &mouse_mode);
> }
>
> -void main_channel_push_agent_connected(Channel *channel)
> +void main_channel_push_agent_connected(MainChannel *main_chan)
> {
> RedsOutItem *item;
> - RedChannelClient *rcc = ((MainChannel*)channel->data)->base.rcc;
> + RedChannelClient *rcc = main_chan->base.rcc;
>
> item = main_pipe_item_new(rcc, SPICE_MSG_MAIN_AGENT_CONNECTED);
> red_channel_client_pipe_add_push(rcc, &item->base);
> }
>
> -void main_channel_push_agent_disconnected(Channel *channel)
> +void main_channel_push_agent_disconnected(MainChannel *main_chan)
> {
> RedsOutItem *item;
> - MainChannel *main_chan = channel->data;
> RedChannelClient *rcc = main_chan->base.rcc;
>
> if (!rcc) {
> @@ -396,10 +389,9 @@ static void main_channel_marshall_agent_disconnected(SpiceMarshaller *m)
> spice_marshall_msg_main_agent_disconnected(m, &disconnect);
> }
>
> -void main_channel_push_tokens(Channel *channel, uint32_t num_tokens)
> +void main_channel_push_tokens(MainChannel *main_chan, uint32_t num_tokens)
> {
> TokensPipeItem *item;
> - MainChannel *main_chan = channel->data;
> RedChannelClient *rcc = main_chan->base.rcc;
>
> if (!rcc) {
> @@ -417,10 +409,9 @@ static void main_channel_marshall_tokens(SpiceMarshaller *m, uint32_t num_tokens
> spice_marshall_msg_main_agent_token(m, &tokens);
> }
>
> -void main_channel_push_agent_data(Channel *channel, uint8_t* data, size_t len,
> +void main_channel_push_agent_data(MainChannel *main_chan, uint8_t* data, size_t len,
> spice_marshaller_item_free_func free_data, void *opaque)
> {
> - MainChannel *main_chan = channel->data;
> RedChannelClient *rcc = main_chan->base.rcc;
> AgentDataPipeItem *item;
>
> @@ -472,26 +463,24 @@ static uint64_t main_channel_handle_migrate_data_get_serial_proc(
> static uint64_t main_channel_handle_migrate_data(RedChannelClient *rcc,
> uint32_t size, void *message)
> {
> - MainChannel *main_chan = SPICE_CONTAINEROF(rcc->channel, MainChannel, base);
> + MainChannelClient *mcc = SPICE_CONTAINEROF(rcc, MainChannelClient, base);
> MainMigrateData *data = message;
>
> if (size < sizeof(*data)) {
> red_printf("bad message size");
> return FALSE;
> }
> - main_chan->ping_id = data->ping_id;
> + mcc->ping_id = data->ping_id;
> reds_on_main_receive_migrate_data(data, ((uint8_t*)message) + size);
> return TRUE;
> }
>
> -void main_channel_push_init(Channel *channel, int connection_id,
> +void main_channel_push_init(RedChannelClient *rcc, int connection_id,
> int display_channels_hint, int current_mouse_mode,
> int is_client_mouse_allowed, int multi_media_time,
> int ram_hint)
> {
> InitPipeItem *item;
> - MainChannel *main_chan = channel->data;
> - RedChannelClient *rcc = main_chan->base.rcc;
>
> item = main_init_item_new(rcc,
> connection_id, display_channels_hint, current_mouse_mode,
> @@ -518,9 +507,8 @@ static void main_channel_marshall_init(SpiceMarshaller *m,
> spice_marshall_msg_main_init(m, &init);
> }
>
> -void main_channel_push_notify(Channel *channel, uint8_t *mess, const int mess_len)
> +void main_channel_push_notify(MainChannel *main_chan, uint8_t *mess, const int mess_len)
> {
> - MainChannel *main_chan = channel->data;
> RedChannelClient *rcc = main_chan->base.rcc;
> NotifyPipeItem *item;
>
> @@ -541,11 +529,10 @@ static void main_channel_marshall_notify(SpiceMarshaller *m, NotifyPipeItem *ite
> spice_marshaller_add(m, item->mess, item->mess_len + 1);
> }
>
> -void main_channel_push_migrate_begin(Channel *channel, int port, int sport,
> +void main_channel_push_migrate_begin(MainChannel *main_chan, int port, int sport,
> char *host, uint16_t cert_pub_key_type, uint32_t cert_pub_key_len,
> uint8_t *cert_pub_key)
> {
> - MainChannel *main_chan = channel->data;
> RedChannelClient *rcc = main_chan->base.rcc;
> MigrateBeginPipeItem *item;
>
> @@ -569,9 +556,8 @@ static void main_channel_marshall_migrate_begin(SpiceMarshaller *m,
> spice_marshall_msg_main_migrate_begin(m, &migrate);
> }
>
> -void main_channel_push_migrate(Channel *channel)
> +void main_channel_push_migrate(MainChannel *main_chan)
> {
> - MainChannel *main_chan = channel->data;
> RedChannelClient *rcc = main_chan->base.rcc;
> RedsOutItem *item;
>
> @@ -587,9 +573,8 @@ static void main_channel_marshall_migrate(SpiceMarshaller *m)
> spice_marshall_msg_migrate(m, &migrate);
> }
>
> -void main_channel_push_migrate_cancel(Channel *channel)
> +void main_channel_push_migrate_cancel(MainChannel *main_chan)
> {
> - MainChannel *main_chan = channel->data;
> RedChannelClient *rcc = main_chan->base.rcc;
> RedsOutItem *item;
>
> @@ -597,9 +582,8 @@ void main_channel_push_migrate_cancel(Channel *channel)
> red_channel_client_pipe_add_push(rcc, &item->base);
> }
>
> -void main_channel_push_multi_media_time(Channel *channel, int time)
> +void main_channel_push_multi_media_time(MainChannel *main_chan, int time)
> {
> - MainChannel *main_chan = channel->data;
> RedChannelClient *rcc = main_chan->base.rcc;
> MultiMediaTimePipeItem *item;
>
> @@ -616,9 +600,8 @@ static PipeItem *main_migrate_switch_item_new(MainChannel *main_chan)
> return item;
> }
>
> -void main_channel_push_migrate_switch(Channel *channel)
> +void main_channel_push_migrate_switch(MainChannel *main_chan)
> {
> - MainChannel *main_chan = channel->data;
> RedChannelClient *rcc = main_chan->base.rcc;
>
> red_channel_client_pipe_add_push(rcc,
> @@ -648,7 +631,7 @@ static void main_channel_marshall_multi_media_time(SpiceMarshaller *m,
>
> static void main_channel_send_item(RedChannelClient *rcc, PipeItem *base)
> {
> - MainChannel *main_chan = SPICE_CONTAINEROF(rcc->channel, MainChannel, base);
> + MainChannelClient *mcc = SPICE_CONTAINEROF(rcc, MainChannelClient, base);
> SpiceMarshaller *m = red_channel_client_get_marshaller(rcc);
>
> red_channel_client_init_send_data(rcc, base->type, base);
> @@ -658,7 +641,7 @@ static void main_channel_send_item(RedChannelClient *rcc, PipeItem *base)
> break;
> case SPICE_MSG_PING:
> main_channel_marshall_ping(m,
> - SPICE_CONTAINEROF(base, PingPipeItem, base)->size, ++main_chan->ping_id);
> + SPICE_CONTAINEROF(base, PingPipeItem, base)->size, ++(mcc->ping_id));
> break;
> case SPICE_MSG_MAIN_MOUSE_MODE:
> {
> @@ -682,7 +665,7 @@ static void main_channel_send_item(RedChannelClient *rcc, PipeItem *base)
> case SPICE_MSG_MIGRATE_DATA:
> main_channel_marshall_migrate_data_item(m,
> red_channel_client_get_message_serial(rcc),
> - main_chan->ping_id);
> + mcc->ping_id);
> break;
> case SPICE_MSG_MAIN_INIT:
> main_channel_marshall_init(m,
> @@ -719,6 +702,7 @@ static void main_channel_release_pipe_item(RedChannelClient *rcc,
> static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint16_t type, void *message)
> {
> MainChannel *main_chan = SPICE_CONTAINEROF(rcc->channel, MainChannel, base);
> + MainChannelClient *mcc = SPICE_CONTAINEROF(rcc, MainChannelClient, base);
>
> switch (type) {
> case SPICE_MSGC_MAIN_AGENT_START:
> @@ -756,19 +740,19 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
> clock_gettime(CLOCK_MONOTONIC, &ts);
> roundtrip = ts.tv_sec * 1000000LL + ts.tv_nsec / 1000LL - ping->timestamp;
>
> - if (ping->id == main_chan->net_test_id) {
> - switch (main_chan->net_test_stage) {
> + if (ping->id == mcc->net_test_id) {
> + switch (mcc->net_test_stage) {
> case NET_TEST_STAGE_WARMUP:
> - main_chan->net_test_id++;
> - main_chan->net_test_stage = NET_TEST_STAGE_LATENCY;
> + mcc->net_test_id++;
> + mcc->net_test_stage = NET_TEST_STAGE_LATENCY;
> break;
> case NET_TEST_STAGE_LATENCY:
> - main_chan->net_test_id++;
> - main_chan->net_test_stage = NET_TEST_STAGE_RATE;
> + mcc->net_test_id++;
> + mcc->net_test_stage = NET_TEST_STAGE_RATE;
> latency = roundtrip;
> break;
> case NET_TEST_STAGE_RATE:
> - main_chan->net_test_id = 0;
> + mcc->net_test_id = 0;
> if (roundtrip <= latency) {
> // probably high load on client or server result with incorrect values
> latency = 0;
> @@ -782,13 +766,13 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
> bitrate_per_sec,
> (double)bitrate_per_sec / 1024 / 1024,
> IS_LOW_BANDWIDTH() ? " LOW BANDWIDTH" : "");
> - main_chan->net_test_stage = NET_TEST_STAGE_INVALID;
> + mcc->net_test_stage = NET_TEST_STAGE_INVALID;
> break;
> default:
> red_printf("invalid net test stage, ping id %d test id %d stage %d",
> ping->id,
> - main_chan->net_test_id,
> - main_chan->net_test_stage);
> + mcc->net_test_id,
> + mcc->net_test_stage);
> }
> break;
> }
> @@ -842,13 +826,14 @@ static int main_channel_handle_migrate_flush_mark_proc(RedChannelClient *rcc)
> return TRUE;
> }
>
> -static void main_channel_link(Channel *channel, RedsStream *stream, int migration,
> +RedChannelClient *main_channel_link(Channel *channel, RedsStream *stream, int migration,
> int num_common_caps, uint32_t *common_caps, int num_caps,
> uint32_t *caps)
> {
> MainChannel *main_chan;
> - ASSERT(channel->data == NULL);
> + RedChannelClient *rcc;
>
> + ASSERT(channel->data == NULL);
> if (channel->data == NULL) {
> red_printf("create main channel");
> channel->data = red_channel_create_parser(
> @@ -870,26 +855,22 @@ static void main_channel_link(Channel *channel, RedsStream *stream, int migratio
> }
> main_chan = (MainChannel*)channel->data;
> red_printf("add main channel client");
> - red_channel_client_create(sizeof(RedChannelClient), channel->data, stream);
> + rcc = red_channel_client_create(sizeof(MainChannelClient), &main_chan->base, stream);
> + return rcc;
> }
>
> -int main_channel_getsockname(Channel *channel, struct sockaddr *sa, socklen_t *salen)
> +int main_channel_getsockname(MainChannel *main_chan, struct sockaddr *sa, socklen_t *salen)
> {
> - MainChannel *main_chan = channel->data;
> -
> return main_chan ? getsockname(red_channel_get_first_socket(&main_chan->base), sa, salen) : -1;
> }
>
> -int main_channel_getpeername(Channel *channel, struct sockaddr *sa, socklen_t *salen)
> +int main_channel_getpeername(MainChannel *main_chan, struct sockaddr *sa, socklen_t *salen)
> {
> - MainChannel *main_chan = channel->data;
> -
> return main_chan ? getpeername(red_channel_get_first_socket(&main_chan->base), sa, salen) : -1;
> }
>
> -void main_channel_close(Channel *channel)
> +void main_channel_close(MainChannel *main_chan)
> {
> - MainChannel *main_chan = channel->data;
> int socketfd;
>
> if (main_chan && (socketfd = red_channel_get_first_socket(&main_chan->base)) != -1) {
> @@ -916,9 +897,8 @@ Channel* main_channel_init(void)
>
> channel = spice_new0(Channel, 1);
> channel->type = SPICE_CHANNEL_MAIN;
> - channel->link = main_channel_link;
> + channel->link = NULL; /* the main channel client is created by reds.c explicitly */
> channel->shutdown = main_channel_shutdown;
> channel->migrate = main_channel_migrate;
> return channel;
> }
> -
> diff --git a/server/main_channel.h b/server/main_channel.h
> index db95dc2..90886df 100644
> --- a/server/main_channel.h
> +++ b/server/main_channel.h
> @@ -21,6 +21,7 @@
> #include <stdint.h>
> #include <spice/vd_agent.h>
> #include "common/marshaller.h"
> +#include "red_channel.h"
>
> /* This is a temporary measure for reds/main split - should not be in a header,
> * but private (although only reds.c includes main_channel.h) */
> @@ -43,31 +44,37 @@ struct MainMigrateData {
> uint32_t write_queue_size;
> };
>
> +typedef struct MainChannel MainChannel;
> +
> Channel *main_channel_init();
> -void main_channel_close(Channel *channel); // not destroy, just socket close
> -int main_channel_push_ping(Channel *channel, int size);
> -void main_channel_push_mouse_mode(Channel *channel, int current_mode, int is_client_mouse_allowed);
> -void main_channel_push_agent_connected(Channel *channel);
> -void main_channel_push_agent_disconnected(Channel *channel);
> -void main_channel_push_tokens(Channel *channel, uint32_t num_tokens);
> -void main_channel_push_agent_data(Channel *channel, uint8_t* data, size_t len,
> +/* This is a 'clone' from the reds.h Channel.link callback */
> +RedChannelClient *main_channel_link(struct Channel *,
> + RedsStream *stream, int migration, int num_common_caps,
> + uint32_t *common_caps, int num_caps, uint32_t *caps);
> +void main_channel_close(MainChannel *main_chan); // not destroy, just socket close
> +int main_channel_push_ping(MainChannel *main_chan, int size);
> +void main_channel_push_mouse_mode(MainChannel *main_chan, int current_mode, int is_client_mouse_allowed);
> +void main_channel_push_agent_connected(MainChannel *main_chan);
> +void main_channel_push_agent_disconnected(MainChannel *main_chan);
> +void main_channel_push_tokens(MainChannel *main_chan, uint32_t num_tokens);
> +void main_channel_push_agent_data(MainChannel *main_chan, uint8_t* data, size_t len,
> spice_marshaller_item_free_func free_data, void *opaque);
> -void main_channel_start_net_test(Channel *channel);
> +void main_channel_start_net_test(RedChannelClient *rcc);
> // TODO: huge. Consider making a reds_* interface for these functions
> // and calling from main.
> -void main_channel_push_init(Channel *channel, int connection_id, int display_channels_hint,
> +void main_channel_push_init(RedChannelClient *rcc, int connection_id, int display_channels_hint,
> int current_mouse_mode, int is_client_mouse_allowed, int multi_media_time,
> int ram_hint);
> -void main_channel_push_notify(Channel *channel, uint8_t *mess, const int mess_len);
> +void main_channel_push_notify(MainChannel *main_chan, uint8_t *mess, const int mess_len);
> // TODO: consider exporting RedsMigSpice from reds.c
> -void main_channel_push_migrate_begin(Channel *channel, int port, int sport, char *host,
> +void main_channel_push_migrate_begin(MainChannel *main_chan, int port, int sport, char *host,
> uint16_t cert_pub_key_type, uint32_t cert_pub_key_len, uint8_t *cert_pub_key);
> -void main_channel_push_migrate(Channel *channel);
> -void main_channel_push_migrate_switch(Channel *channel);
> -void main_channel_push_migrate_cancel(Channel *channel);
> -void main_channel_push_multi_media_time(Channel *channel, int time);
> -int main_channel_getsockname(Channel *channel, struct sockaddr *sa, socklen_t *salen);
> -int main_channel_getpeername(Channel *channel, struct sockaddr *sa, socklen_t *salen);
> +void main_channel_push_migrate(MainChannel *main_chan);
> +void main_channel_push_migrate_switch(MainChannel *main_chan);
> +void main_channel_push_migrate_cancel(MainChannel *main_chan);
> +void main_channel_push_multi_media_time(MainChannel *main_chan, int time);
> +int main_channel_getsockname(MainChannel *main_chan, struct sockaddr *sa, socklen_t *salen);
> +int main_channel_getpeername(MainChannel *main_chan, struct sockaddr *sa, socklen_t *salen);
>
> // TODO: Defines used to calculate receive buffer size, and also by reds.c
> // other options: is to make a reds_main_consts.h, to duplicate defines.
> @@ -75,4 +82,3 @@ int main_channel_getpeername(Channel *channel, struct sockaddr *sa, socklen_t *s
> #define REDS_NUM_INTERNAL_AGENT_MESSAGES 1
>
> #endif
> -
> diff --git a/server/red_channel.c b/server/red_channel.c
> index e29c5d2..2b76f31 100644
> --- a/server/red_channel.c
> +++ b/server/red_channel.c
> @@ -357,7 +357,7 @@ static void red_channel_client_pipe_remove(RedChannelClient *rcc, PipeItem *item
>
> static void red_channel_add_client(RedChannel *channel, RedChannelClient *rcc)
> {
> - ASSERT(rcc);
> + ASSERT(rcc && !channel->rcc);
I know this is not respected everywhere, but we should avoid checking
several conditions in one assert(). Please add a second assert()
instead.
> channel->rcc = rcc;
> }
>
> @@ -366,7 +366,7 @@ RedChannelClient *red_channel_client_create(
> RedChannel *channel,
> RedsStream *stream)
> {
> - RedChannelClient *rcc = NULL;
> + RedChannelClient *rcc;
>
> ASSERT(stream && channel && size >= sizeof(RedChannelClient));
> rcc = spice_malloc0(size);
> diff --git a/server/reds.c b/server/reds.c
> index cd86ab9..9ed7d17 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -199,7 +199,8 @@ typedef struct RedsState {
> VDIPortState agent_state;
> int pending_mouse_event;
> uint32_t link_id;
> - Channel *main_channel;
> + Channel *main_channel_factory;
> + MainChannel *main_channel;
>
> int mig_wait_connect;
> int mig_wait_disconnect;
> @@ -615,7 +616,8 @@ void reds_disconnect()
> }
>
> reds_shatdown_channels();
> - reds->main_channel->shutdown(reds->main_channel);
> + reds->main_channel_factory->shutdown(reds->main_channel_factory);
> + reds->main_channel_factory->data = NULL;
> reds->main_channel = NULL;
> reds_mig_cleanup();
> reds->disconnecting = FALSE;
> @@ -1512,13 +1514,14 @@ static void reds_send_link_result(RedLinkInfo *link, uint32_t error)
> }
>
> // TODO: now that main is a separate channel this should
> -// actually be joined with reds_handle_other_links, ebcome reds_handle_link
> +// actually be joined with reds_handle_other_links, become reds_handle_link
> static void reds_handle_main_link(RedLinkInfo *link)
> {
> RedsStream *stream;
> SpiceLinkMess *link_mess;
> uint32_t *caps;
> uint32_t connection_id;
> + RedChannelClient *rcc;
>
> red_printf("");
> link_mess = link->link_mess;
> @@ -1553,11 +1556,15 @@ static void reds_handle_main_link(RedLinkInfo *link)
> link->link_mess = NULL;
> reds_link_free(link);
> caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset);
> - reds->main_channel = main_channel_init();
> - reds->main_channel->link(reds->main_channel, stream, reds->mig_target, link_mess->num_common_caps,
> + if (!reds->main_channel_factory) {
> + reds->main_channel_factory = main_channel_init();
> + }
> + rcc = main_channel_link(reds->main_channel_factory,
> + stream, reds->mig_target, link_mess->num_common_caps,
> link_mess->num_common_caps ? caps : NULL, link_mess->num_channel_caps,
> link_mess->num_channel_caps ? caps + link_mess->num_common_caps : NULL);
> free(link_mess);
> + reds->main_channel = (MainChannel*)rcc->channel;
>
> if (vdagent) {
> SpiceCharDeviceInterface *sif;
> @@ -1572,12 +1579,12 @@ static void reds_handle_main_link(RedLinkInfo *link)
>
> if (!reds->mig_target) {
> reds->agent_state.num_client_tokens = REDS_AGENT_WINDOW_SIZE;
> - main_channel_push_init(reds->main_channel, connection_id, red_dispatcher_count(),
> + main_channel_push_init(rcc, connection_id, red_dispatcher_count(),
> reds->mouse_mode, reds->is_client_mouse_allowed,
> reds_get_mm_time() - MM_TIME_DELTA,
> red_dispatcher_qxl_ram_size());
>
> - main_channel_start_net_test(reds->main_channel);
> + main_channel_start_net_test(rcc);
> /* Now that we have a client, forward any pending agent data */
> while (read_from_vdi_port());
> }
> --
> 1.7.4.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
--
Marc-André Lureau
More information about the Spice-devel
mailing list