[Spice-devel] [PATCH spice-server 4/6] red-channel-client: Move incoming/ougoing initialization to constructor

Frediano Ziglio fziglio at redhat.com
Fri Oct 28 10:59:54 UTC 2016


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 <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



More information about the Spice-devel mailing list