[Spice-commits] 3 commits - server/dummy-channel-client.c server/red-channel-client.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Wed Nov 2 15:48:58 UTC 2016


 server/dummy-channel-client.c |    2 -
 server/red-channel-client.c   |   49 ++++++++++++++++++++++--------------------
 2 files changed, 26 insertions(+), 25 deletions(-)

New commits:
commit 654dfa4ca5fc443cefbc43a5cbdcf3a9b43292fc
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Oct 27 13:25:40 2016 +0100

    red-channel-client: Change initialization order
    
    Make the order of initialization closer to what it was before
    conversion to GObject.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index ad6b3e6..a28f5e6 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -896,7 +896,22 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
         goto cleanup;
     }
 
+    if (!red_channel_config_socket(self->priv->channel, self)) {
+        g_set_error_literal(&local_error,
+                            SPICE_SERVER_ERROR,
+                            SPICE_SERVER_ERROR_FAILED,
+                            "Unable to configure socket");
+        goto cleanup;
+    }
+
     core = red_channel_get_core_interface(self->priv->channel);
+    if (self->priv->stream)
+        self->priv->stream->watch =
+            core->watch_add(core, self->priv->stream->socket,
+                            SPICE_WATCH_EVENT_READ,
+                            red_channel_client_event,
+                            self);
+
     if (self->priv->monitor_latency
         && reds_stream_get_family(self->priv->stream) != AF_UNIX) {
         self->priv->latency_monitor.timer =
@@ -909,22 +924,9 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
         self->priv->latency_monitor.roundtrip = -1;
     }
 
-    if (self->priv->stream)
-        self->priv->stream->watch =
-            core->watch_add(core, self->priv->stream->socket,
-                            SPICE_WATCH_EVENT_READ,
-                            red_channel_client_event,
-                            self);
     red_channel_add_client(self->priv->channel, self);
     red_client_add_channel(self->priv->client, self);
 
-    if (!red_channel_config_socket(self->priv->channel, self)) {
-        g_set_error_literal(&local_error,
-                            SPICE_SERVER_ERROR,
-                            SPICE_SERVER_ERROR_FAILED,
-                            "Unable to configure socket");
-    }
-
 cleanup:
     pthread_mutex_unlock(&self->priv->client->lock);
     if (local_error) {
commit bac3a682c86f39c7ab1e73ca2559f2719f8c5e76
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Oct 27 13:25:17 2016 +0100

    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 <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

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 3b8cc7b..ad6b3e6 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,
commit f5c0e555d367d37f7bd1bfa1c618f6c58d93d39c
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Oct 27 13:24:20 2016 +0100

    red-channel-client: Init pipe field during init
    
    There was a chance that on error GQueue were not
    initialized but an attempt to destroy it is made.
    This ensures GQueue is initialized as soon as
    possible. Note that red_channel_client_initable_init
    is called after all init and construction callbacks.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 1981805..3b8cc7b 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -354,6 +354,8 @@ red_channel_client_init(RedChannelClient *self)
     self->priv->send_data.urgent.marshaller = spice_marshaller_new();
 
     self->priv->send_data.marshaller = self->priv->send_data.main.marshaller;
+
+    g_queue_init(&self->priv->pipe);
 }
 
 RedChannel* red_channel_client_get_channel(RedChannelClient *rcc)
@@ -907,7 +909,6 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
     self->priv->outgoing.pos = 0;
     self->priv->outgoing.size = 0;
 
-    g_queue_init(&self->priv->pipe);
     if (self->priv->stream)
         self->priv->stream->watch =
             core->watch_add(core, self->priv->stream->socket,


More information about the Spice-commits mailing list