[gnome-session] manager: fix deadlock when registering XSMP clients at login



commit 6c24fcc915019ebb93fa25866ba17cd668656338
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Sep 2 02:16:34 2013 -0700

    manager: fix deadlock when registering XSMP clients at login
    
    gnome-session will switch to the next phase whenever the list of
    applications pending registration is emptied.
    Previously, for XSMP clients, the code in GsmXSMPClient would signal
    that an application was registered before sending the reply through
    SmsRegisterClientReply().
    As GnomeIdleMonitor will now call into Mutter through DBus, and the
    RUNNING phase of the session will initialize its presence component that
    uses the monitor, we will end up in a situation where Mutter is waiting
    for the XSMP reply from gnome-session, and gnome-session is waiting for
    a synchronous DBus reply from Mutter, effectively locking up the login
    process until the DBus timeout occurs.
    
    This commit fixes the bug by signalling XSMP app registration only after
    the reply has been sent over the wire.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707274

 gnome-session/gsm-manager.c     |   19 ++++++++++++++++++-
 gnome-session/gsm-xsmp-client.c |   13 +++++++++++++
 gnome-session/gsm-xsmp-client.h |    2 ++
 3 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index d2f375d..351d628 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -2116,7 +2116,6 @@ on_xsmp_client_register_request (GsmXSMPClient *client,
         app = find_app_for_startup_id (manager, new_id);
         if (app != NULL) {
                 gsm_client_set_app_id (GSM_CLIENT (client), gsm_app_peek_app_id (app));
-                gsm_app_registered (app);
                 goto out;
         }
 
@@ -2131,6 +2130,20 @@ on_xsmp_client_register_request (GsmXSMPClient *client,
         return handled;
 }
 
+static void
+on_xsmp_client_register_confirmed (GsmXSMPClient *client,
+                                   const gchar   *id,
+                                   GsmManager    *manager)
+{
+        GsmApp *app;
+
+        app = find_app_for_startup_id (manager, id);
+
+        if (app != NULL) {
+                gsm_app_registered (app);
+        }
+}
+
 static gboolean
 auto_save_is_enabled (GsmManager *manager)
 {
@@ -2313,6 +2326,10 @@ on_store_client_added (GsmStore   *store,
                                   G_CALLBACK (on_xsmp_client_register_request),
                                   manager);
                 g_signal_connect (client,
+                                  "register-confirmed",
+                                  G_CALLBACK (on_xsmp_client_register_confirmed),
+                                  manager);
+                g_signal_connect (client,
                                   "logout-request",
                                   G_CALLBACK (on_xsmp_client_logout_request),
                                   manager);
diff --git a/gnome-session/gsm-xsmp-client.c b/gnome-session/gsm-xsmp-client.c
index f84fab3..f52d29f 100644
--- a/gnome-session/gsm-xsmp-client.c
+++ b/gnome-session/gsm-xsmp-client.c
@@ -66,6 +66,7 @@ enum {
 
 enum {
         REGISTER_REQUEST,
+        REGISTER_CONFIRMED,
         LOGOUT_REQUEST,
         LAST_SIGNAL
 };
@@ -1002,6 +1003,16 @@ gsm_xsmp_client_class_init (GsmXSMPClientClass *klass)
                               NULL,
                               G_TYPE_BOOLEAN,
                               1, G_TYPE_POINTER);
+        signals[REGISTER_CONFIRMED] =
+                g_signal_new ("register-confirmed",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmXSMPClientClass, register_confirmed),
+                              NULL,
+                              NULL,
+                              NULL,
+                              G_TYPE_NONE,
+                              1, G_TYPE_POINTER);
         signals[LOGOUT_REQUEST] =
                 g_signal_new ("logout-request",
                               G_OBJECT_CLASS_TYPE (object_class),
@@ -1089,6 +1100,8 @@ register_client_callback (SmsConn    conn,
 
         gsm_client_set_status (GSM_CLIENT (client), GSM_CLIENT_REGISTERED);
 
+        g_signal_emit (client, signals[REGISTER_CONFIRMED], 0, id);
+
         g_free (id);
         free (previous_id);
 
diff --git a/gnome-session/gsm-xsmp-client.h b/gnome-session/gsm-xsmp-client.h
index b80f933..f98967d 100644
--- a/gnome-session/gsm-xsmp-client.h
+++ b/gnome-session/gsm-xsmp-client.h
@@ -52,6 +52,8 @@ struct _GsmXSMPClientClass
         /* signals */
         gboolean (*register_request)     (GsmXSMPClient  *client,
                                           char          **client_id);
+        void     (*register_confirmed)   (GsmXSMPClient  *client,
+                                          const char     *client_id);
         gboolean (*logout_request)       (GsmXSMPClient  *client,
                                           gboolean        prompt);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]