[Spice-devel] [PATCH spice-server 5/6] red-channel-client: Change initialization order

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


A bit more similar to previous

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-channel-client.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 6c78237..42f1d2c 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,23 +924,10 @@ 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);
     self->priv->id = red_channel_get_n_clients(self->priv->channel);
     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) {
-- 
2.7.4



More information about the Spice-devel mailing list