diff options
author | Dan Williams <dcbw@redhat.com> | 2014-05-01 09:51:45 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-05-06 14:13:36 -0500 |
commit | 408b88ccc38d6fa65ba7be7affb5e4bf40f4945b (patch) | |
tree | 9664d8e86d79ccac14a0d7a4225a7846950df69c | |
parent | ab35481ce58258e80db6bef833c8c62e1190db08 (diff) | |
download | network-manager-applet-408b88ccc38d6fa65ba7be7affb5e4bf40f4945b.tar.gz |
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
-rw-r--r-- | src/applet.c | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/src/applet.c b/src/applet.c index 59691f60..f95d20b2 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 */ |