[gnome-session] manager: remove client from query clients list on disconnect



commit 8e6afcf1789c02692cf3b1ff3ee0a792d57e17a3
Author: Ray Strode <rstrode redhat com>
Date:   Sun Nov 7 12:32:17 2010 -0500

    manager: remove client from query clients list on disconnect
    
    When the session manager enters the query end session phase,
    it temporarily adds all clients to the "query clients" list.
    
    This list is used to track the progression of clients quitting.
    
    If a client quits during the query end session phase instead of
    waiting until the end session phase, then it will get destroyed
    but not get removed from the query clients list.
    
    This commit removes it from the query clients list in
    this case. It does this by explicitly invoking the end session
    response handler (in effect, the client responded to the end
    session query by exiting).

 gnome-session/gsm-manager.c |   53 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 47 insertions(+), 6 deletions(-)
---
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index d15402f..d1fecb9 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -164,6 +164,13 @@ static void     gsm_manager_finalize    (GObject         *object);
 static gboolean auto_save_is_enabled (GsmManager *manager);
 static void     maybe_save_session   (GsmManager *manager);
 
+static void     _handle_client_end_session_response (GsmManager *manager,
+                                                     GsmClient  *client,
+                                                     gboolean    is_ok,
+                                                     gboolean    do_last,
+                                                     gboolean    cancel,
+                                                     const char *reason);
+
 static gpointer manager_object = NULL;
 
 G_DEFINE_TYPE (GsmManager, gsm_manager, G_TYPE_OBJECT)
@@ -1516,6 +1523,24 @@ _disconnect_client (GsmManager *manager,
                 }
         }
 
+        if (manager->priv->phase == GSM_MANAGER_PHASE_QUERY_END_SESSION) {
+                /* Instead of answering our end session query, the client just exited.
+                 * Treat that as an "okay, end the session" answer.
+                 *
+                 * This call implicitly removes any inhibitors for the client, along
+                 * with removing the client from the pending query list.
+                 */
+                _handle_client_end_session_response (manager,
+                                                     client,
+                                                     TRUE,
+                                                     FALSE,
+                                                     FALSE,
+                                                     "Client exited in "
+                                                     "query end session phase "
+                                                     "instead of end session "
+                                                     "phase");
+        }
+
         if (app == NULL) {
                 g_debug ("GsmManager: unable to find application for client - not restarting");
                 goto out;
@@ -1862,12 +1887,12 @@ out:
 }
 
 static void
-on_client_end_session_response (GsmClient  *client,
-                                gboolean    is_ok,
-                                gboolean    do_last,
-                                gboolean    cancel,
-                                const char *reason,
-                                GsmManager *manager)
+_handle_client_end_session_response (GsmManager *manager,
+                                     GsmClient  *client,
+                                     gboolean    is_ok,
+                                     gboolean    do_last,
+                                     gboolean    cancel,
+                                     const char *reason)
 {
         /* just ignore if received outside of shutdown */
         if (manager->priv->phase < GSM_MANAGER_PHASE_QUERY_END_SESSION) {
@@ -1952,6 +1977,22 @@ on_client_end_session_response (GsmClient  *client,
 }
 
 static void
+on_client_end_session_response (GsmClient  *client,
+                                gboolean    is_ok,
+                                gboolean    do_last,
+                                gboolean    cancel,
+                                const char *reason,
+                                GsmManager *manager)
+{
+        _handle_client_end_session_response (manager,
+                                             client,
+                                             is_ok,
+                                             do_last,
+                                             cancel,
+                                             reason);
+}
+
+static void
 on_xsmp_client_logout_request (GsmXSMPClient *client,
                                gboolean       show_dialog,
                                GsmManager    *manager)



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