[network-manager-applet] applet: don't block on ModemManager initialization (bgo #729334)



commit 408b88ccc38d6fa65ba7be7affb5e4bf40f4945b
Author: Dan Williams <dcbw redhat com>
Date:   Thu May 1 09:51:45 2014 -0500

    applet: don't block on ModemManager initialization (bgo #729334)
    
    First, don't autostart ModemManager since the applet is only using
    ModemManager for information and not for controlling modems.  Leave
    that to system services (like systemd or upstart).  Requesting
    autostart can block for long periods of time in some situations,
    like if the process hangs during startup or isn't actually present
    on the disk.
    
    Second, make ModemManager initialization asynchronous to avoid any
    other initialization blockage.  The applet only uses MM for info
    about devices NM already knows about, so it's not critical to
    applet startup.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=729334

 src/applet.c |   54 +++++++++++++++++++++++++++++++-----------------------
 1 files changed, 31 insertions(+), 23 deletions(-)
---
diff --git a/src/applet.c b/src/applet.c
index 59691f6..f95d20b 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -2703,37 +2703,45 @@ mm1_name_owner_changed_cb (GDBusObjectManagerClient *mm1,
 }
 
 static void
-mm1_client_setup (NMApplet *applet)
+mm_new_ready (GDBusConnection *connection,
+              GAsyncResult *res,
+              NMApplet *applet)
 {
-       GDBusConnection *system_bus;
        GError *error = NULL;
 
-       system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
-       if (!system_bus) {
-               g_warning ("Error connecting to system D-Bus: %s",
-                          error->message);
+       applet->mm1 = mm_manager_new_finish (res, &error);
+       if (applet->mm1) {
+               /* We've got our MM proxy, now check whether the ModemManager
+                * is really running and usable */
+               g_signal_connect (applet->mm1,
+                                 "notify::name-owner",
+                                 G_CALLBACK (mm1_name_owner_changed_cb),
+                                 applet);
+               mm1_name_owner_changed_cb (G_DBUS_OBJECT_MANAGER_CLIENT (applet->mm1), NULL, applet);
+       } else {
+               g_warning ("Error connecting to D-Bus: %s", error->message);
                g_clear_error (&error);
-               return;
        }
+}
 
-       applet->mm1 = (mm_manager_new_sync (
-                              system_bus,
-                              G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
-                              NULL,
-                              &error));
-       if (!applet->mm1) {
-               g_warning ("Error connecting to ModemManager: %s",
-                          error->message);
+static void
+mm1_client_setup (NMApplet *applet)
+{
+       GDBusConnection *system_bus;
+       GError *error = NULL;
+
+       system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (system_bus) {
+               mm_manager_new (system_bus,
+                               G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START,
+                               NULL,
+                               (GAsyncReadyCallback) mm_new_ready,
+                               applet);
+               g_object_unref (system_bus);
+       } else {
+               g_warning ("Error connecting to system D-Bus: %s", error->message);
                g_clear_error (&error);
-               return;
        }
-
-       /* Check whether the ModemManager is really running */
-       g_signal_connect (applet->mm1,
-                         "notify::name-owner",
-                         G_CALLBACK (mm1_name_owner_changed_cb),
-                         applet);
-       mm1_name_owner_changed_cb (G_DBUS_OBJECT_MANAGER_CLIENT (applet->mm1), NULL, applet);
 }
 
 #endif /* WITH_MODEM_MANAGER_1 */


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