From bac3a682c86f39c7ab1e73ca2559f2719f8c5e76 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Thu, 27 Oct 2016 13:25:17 +0100 Subject: [PATCH] red-channel-client: Move incoming/ougoing initialization to constructor 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. Signed-off-by: Frediano Ziglio Acked-by: Jonathon Jongsma --- 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 b7fee6fa..a242d512 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 3b8cc7bc..ad6b3e62 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,