[Spice-devel] [PATCH spice-server 4/6] red-channel-client: Move incoming/ougoing initialization to constructor
Christophe Fergeau
cfergeau at redhat.com
Fri Oct 28 12:48:15 UTC 2016
On Fri, Oct 28, 2016 at 11:59:54AM +0100, Frediano Ziglio wrote:
> These fields need just channel to be set to be initialized.
> Move their initialization to constructor to make sure
> they are initialized as soon as possible.
Why?
Not related to this patch, but I'm not sure initializing pos and size to
0 is required, 'priv' will be memset to 0 upon creation.
Christophe
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/dummy-channel-client.c | 2 --
> server/red-channel-client.c | 18 +++++++++---------
> 2 files changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/server/dummy-channel-client.c b/server/dummy-channel-client.c
> index b7fee6f..a242d51 100644
> --- a/server/dummy-channel-client.c
> +++ b/server/dummy-channel-client.c
> @@ -70,8 +70,6 @@ static gboolean dummy_channel_client_initable_init(GInitable *initable,
> goto cleanup;
> }
>
> - rcc->incoming.header.data = rcc->incoming.header_buf;
> -
> red_channel_add_client(channel, rcc);
> red_client_add_channel(client, rcc);
>
> diff --git a/server/red-channel-client.c b/server/red-channel-client.c
> index 3b2c24c..6c78237 100644
> --- a/server/red-channel-client.c
> +++ b/server/red-channel-client.c
> @@ -269,6 +269,14 @@ static void red_channel_client_constructed(GObject *object)
> {
> RedChannelClient *self = RED_CHANNEL_CLIENT(object);
>
> + self->incoming.opaque = self;
> + self->incoming.cb = red_channel_get_incoming_handler(self->priv->channel);
> +
> + self->priv->outgoing.opaque = self;
> + self->priv->outgoing.cb = red_channel_get_outgoing_handler(self->priv->channel);
> + self->priv->outgoing.pos = 0;
> + self->priv->outgoing.size = 0;
> +
> if (red_channel_client_test_remote_common_cap(self, SPICE_COMMON_CAP_MINI_HEADER)) {
> self->incoming.header = mini_header_wrapper;
> self->priv->send_data.header = mini_header_wrapper;
> @@ -278,6 +286,7 @@ static void red_channel_client_constructed(GObject *object)
> self->priv->send_data.header = full_header_wrapper;
> self->priv->is_mini_header = FALSE;
> }
> + self->incoming.header.data = self->incoming.header_buf;
> }
>
> static void red_channel_client_class_init(RedChannelClientClass *klass)
> @@ -900,15 +909,6 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
> self->priv->latency_monitor.roundtrip = -1;
> }
>
> - self->incoming.opaque = self;
> - self->incoming.cb = red_channel_get_incoming_handler(self->priv->channel);
> - self->incoming.header.data = self->incoming.header_buf;
> -
> - self->priv->outgoing.opaque = self;
> - self->priv->outgoing.cb = red_channel_get_outgoing_handler(self->priv->channel);
> - self->priv->outgoing.pos = 0;
> - self->priv->outgoing.size = 0;
> -
> if (self->priv->stream)
> self->priv->stream->watch =
> core->watch_add(core, self->priv->stream->socket,
> --
> 2.7.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20161028/976b638a/attachment-0001.sig>
More information about the Spice-devel
mailing list