[Spice-devel] [RFC v4 12/62] server/main_channel+reds: make main_channel_init return MainChannelClient

Marc-André Lureau marcandre.lureau at gmail.com
Mon May 2 16:53:06 PDT 2011


The description doesn't describe the changes correctly.

This patch also partially address and worsen the main_channel_foo()
consistency evoked in 07/62 review.

On Tue, Apr 26, 2011 at 12:54 PM, Alon Levy <alevy at redhat.com> wrote:
> This makes it easier to introduce RedClient in the next patch.
> ---
>  server/main_channel.c |   27 +++++++++++++--------------
>  server/main_channel.h |    7 ++++---
>  server/reds.c         |   11 ++++++-----
>  3 files changed, 23 insertions(+), 22 deletions(-)
>
> diff --git a/server/main_channel.c b/server/main_channel.c
> index 5b175de..863fc85 100644
> --- a/server/main_channel.c
> +++ b/server/main_channel.c
> @@ -146,16 +146,14 @@ static void main_disconnect(MainChannel *main_chan)
>
>  static int main_channel_client_push_ping(RedChannelClient *rcc, int size);
>
> -void main_channel_start_net_test(RedChannelClient *rcc)
> +void main_channel_start_net_test(MainChannelClient *mcc)
>  {
> -    MainChannelClient *mcc = SPICE_CONTAINEROF(rcc, MainChannelClient, base);
> -
> -    if (!rcc) {
> +    if (!mcc) {
>         return;
>     }
> -    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)) {
> +    if (main_channel_client_push_ping(&mcc->base, NET_TEST_WARMUP_BYTES)
> +        && main_channel_client_push_ping(&mcc->base, 0)
> +        && main_channel_client_push_ping(&mcc->base, NET_TEST_BYTES)) {
>         mcc->net_test_id = mcc->ping_id - 2;
>         mcc->net_test_stage = NET_TEST_STAGE_WARMUP;
>     }
> @@ -475,17 +473,17 @@ static uint64_t main_channel_handle_migrate_data(RedChannelClient *rcc,
>     return TRUE;
>  }
>
> -void main_channel_push_init(RedChannelClient *rcc, int connection_id,
> +void main_channel_push_init(MainChannelClient *mcc, 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;
>
> -    item = main_init_item_new(rcc,
> +    item = main_init_item_new(&mcc->base,
>              connection_id, display_channels_hint, current_mouse_mode,
>              is_client_mouse_allowed, multi_media_time, ram_hint);
> -    red_channel_client_pipe_add_push(rcc, &item->base);
> +    red_channel_client_pipe_add_push(&mcc->base, &item->base);
>  }
>
>  static void main_channel_marshall_init(SpiceMarshaller *m,
> @@ -826,12 +824,12 @@ static int main_channel_handle_migrate_flush_mark_proc(RedChannelClient *rcc)
>     return TRUE;
>  }
>
> -RedChannelClient *main_channel_link(Channel *channel, RedsStream *stream, int migration,
> +MainChannelClient *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;
> -    RedChannelClient *rcc;
> +    MainChannelClient *mcc;
>
>     ASSERT(channel->data == NULL);
>     if (channel->data == NULL) {
> @@ -855,8 +853,9 @@ RedChannelClient *main_channel_link(Channel *channel, RedsStream *stream, int mi
>     }
>     main_chan = (MainChannel*)channel->data;
>     red_printf("add main channel client");
> -    rcc = red_channel_client_create(sizeof(MainChannelClient), &main_chan->base, stream);
> -    return rcc;
> +    mcc = (MainChannelClient*)
> +            red_channel_client_create(sizeof(MainChannelClient), &main_chan->base, stream);
> +    return mcc;
>  }
>
>  int main_channel_getsockname(MainChannel *main_chan, struct sockaddr *sa, socklen_t *salen)
> diff --git a/server/main_channel.h b/server/main_channel.h
> index 90886df..ce012d2 100644
> --- a/server/main_channel.h
> +++ b/server/main_channel.h
> @@ -45,10 +45,11 @@ struct MainMigrateData {
>  };
>
>  typedef struct MainChannel MainChannel;
> +typedef struct MainChannelClient MainChannelClient;
>
>  Channel *main_channel_init();
>  /* This is a 'clone' from the reds.h Channel.link callback */
> -RedChannelClient *main_channel_link(struct Channel *,
> +MainChannelClient *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
> @@ -59,10 +60,10 @@ 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(RedChannelClient *rcc);
> +void main_channel_start_net_test(MainChannelClient *mcc);
>  // TODO: huge. Consider making a reds_* interface for these functions
>  // and calling from main.
> -void main_channel_push_init(RedChannelClient *rcc, int connection_id, int display_channels_hint,
> +void main_channel_push_init(MainChannelClient *mcc, 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(MainChannel *main_chan, uint8_t *mess, const int mess_len);
> diff --git a/server/reds.c b/server/reds.c
> index 9ed7d17..5aeb2b8 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -1521,7 +1521,7 @@ static void reds_handle_main_link(RedLinkInfo *link)
>     SpiceLinkMess *link_mess;
>     uint32_t *caps;
>     uint32_t connection_id;
> -    RedChannelClient *rcc;
> +    MainChannelClient *mcc;
>
>     red_printf("");
>     link_mess = link->link_mess;
> @@ -1559,12 +1559,13 @@ static void reds_handle_main_link(RedLinkInfo *link)
>     if (!reds->main_channel_factory) {
>         reds->main_channel_factory = main_channel_init();
>     }
> -    rcc = main_channel_link(reds->main_channel_factory,
> +    mcc = 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);
> +    reds->main_channel = (MainChannel*)reds->main_channel_factory->data;
> +    ASSERT(reds->main_channel);
>     free(link_mess);
> -    reds->main_channel = (MainChannel*)rcc->channel;
>
>     if (vdagent) {
>         SpiceCharDeviceInterface *sif;
> @@ -1579,12 +1580,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(rcc, connection_id, red_dispatcher_count(),
> +        main_channel_push_init(mcc, 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(rcc);
> +        main_channel_start_net_test(mcc);
>         /* 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