[gdm] Add maybe_set_is_loaded function



commit 0607c09940578741e2a5e1fe00c71ea7fba90fe7
Author: Ray Strode <rstrode redhat com>
Date:   Wed Jun 23 22:19:20 2010 -0400

    Add maybe_set_is_loaded function
    
    The is-loaded property is set when the user manager has finished
    doing its various asynchronous tasks related to conjuring the
    list of users available on the system.
    
    The property value changing to TRUE signifies that the
    gdm_user_manager_list_users function can legally be called.
    
    Concretely, is-loaded should only be set to TRUE when both the
    passwd file and ConsoleKit history file have finished loading,
    or when the accounts service has finished returning its list
    of available users.
    
    This commit enforces the above non-accounts service related
    invariants more explicitly by replacing all set_is_loaded calls
    with a new function maybe_set_is_loaded that does the
    prerequisite checks.
    
    This means as the code evolves, if there are future asynchronous
    tasks to wait on, one function can be modified instead of
    several.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=622639
    (cherry picked from commit fe4960c1c6a9b1bf290cae7fd7b387c8fb1fbc9b)

 gui/simple-greeter/gdm-user-manager.c |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-user-manager.c b/gui/simple-greeter/gdm-user-manager.c
index 995544d..48b7fc5 100644
--- a/gui/simple-greeter/gdm-user-manager.c
+++ b/gui/simple-greeter/gdm-user-manager.c
@@ -1349,6 +1349,24 @@ process_ck_history_line (GdmUserManager *manager,
         g_free (username);
 }
 
+static void
+maybe_set_is_loaded (GdmUserManager *manager)
+{
+        if (manager->priv->is_loaded) {
+                return;
+        }
+
+        if (manager->priv->ck_history_pid != 0) {
+                return;
+        }
+
+        if (manager->priv->load_passwd_pending) {
+                return;
+        }
+
+        set_is_loaded (manager, TRUE);
+}
+
 static gboolean
 ck_history_watch (GIOChannel     *source,
                   GIOCondition    condition,
@@ -1390,9 +1408,7 @@ ck_history_watch (GIOChannel     *source,
                 }
                 manager->priv->ck_history_pid = 0;
 
-                if (! manager->priv->load_passwd_pending) {
-                        set_is_loaded (manager, TRUE);
-                }
+                maybe_set_is_loaded (manager);
 
                 return FALSE;
         }
@@ -1741,21 +1757,16 @@ reload_passwd_job_done (PasswdData *data)
                 remove_user (data->manager, l->data);
         }
 
+        data->manager->priv->load_passwd_pending = FALSE;
+
         if (! data->manager->priv->is_loaded) {
-                /* if there is an outstanding history
-                   request then wait to emit loaded */
-                if (data->manager->priv->ck_history_pid == 0) {
-                        set_is_loaded (data->manager, TRUE);
-                }
+                maybe_set_is_loaded (data->manager);
 
                 if (data->manager->priv->include_all == TRUE) {
                         monitor_local_users (data->manager);
                 }
         }
 
-        data->manager->priv->load_passwd_pending = FALSE;
-
-
         passwd_data_free (data);
 
         return FALSE;



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