[Spice-devel] [PATCH] Guarantee that 'uuid' property is notified after connection

Jonathon Jongsma jjongsma at redhat.com
Thu Nov 7 09:38:45 PST 2013


This creates a synchronization point and allows API users to rely on the fact
that they'll always get a UUID notification before all of the channels are
created.
---
 gtk/channel-main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 5c33e67..c2d298e 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -83,6 +83,7 @@ struct _SpiceMainChannelPrivate  {
     gboolean                    display_disable_animation:1;
     gboolean                    disable_display_position:1;
     gboolean                    disable_display_align:1;
+    gboolean                    did_receive_uuid:1;
 
     int                         agent_tokens;
     VDAgentMessage              agent_msg; /* partial msg reconstruction */
@@ -1477,12 +1478,14 @@ static void main_handle_name(SpiceChannel *channel, SpiceMsgIn *in)
 /* coroutine context */
 static void main_handle_uuid(SpiceChannel *channel, SpiceMsgIn *in)
 {
+    SpiceMainChannel *c = SPICE_MAIN_CHANNEL(channel);
     SpiceMsgMainUuid *uuid = spice_msg_in_parsed(in);
     SpiceSession *session = spice_channel_get_session(channel);
     gchar *uuid_str = spice_uuid_to_string(uuid->uuid);
 
     SPICE_DEBUG("server uuid: %s", uuid_str);
     spice_session_set_uuid(session, uuid->uuid);
+    c->priv->did_receive_uuid = TRUE;
 
     g_free(uuid_str);
 }
@@ -1519,11 +1522,18 @@ static gboolean _channel_new(channel_new_t *c)
 /* coroutine context */
 static void main_handle_channels_list(SpiceChannel *channel, SpiceMsgIn *in)
 {
+    SpiceMainChannel *main_channel = SPICE_MAIN_CHANNEL(channel);
     SpiceMsgChannels *msg = spice_msg_in_parsed(in);
     SpiceSession *session;
     int i;
 
     session = spice_channel_get_session(channel);
+
+    /* guarantee that uuid is notified before setting up the channels, even if
+     * the server is older and doesn't actually send the uuid */
+    if (!main_channel->priv->did_receive_uuid)
+        g_object_notify_main_context(G_OBJECT(session), "uuid");
+
     for (i = 0; i < msg->num_of_channels; i++) {
         channel_new_t *c;
 
-- 
1.8.3.1



More information about the Spice-devel mailing list