[network-manager-applet/dcbw/fixes: 2/2] applet: don't block on ModemManager initialization
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/dcbw/fixes: 2/2] applet: don't block on ModemManager initialization
- Date: Mon, 5 May 2014 20:55:07 +0000 (UTC)
commit e727ce3cbde8a2dd89962dac993da2a6ec1680a4
Author: Dan Williams <dcbw redhat com>
Date: Thu May 1 09:51:45 2014 -0500
applet: don't block on ModemManager initialization
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.
src/applet.c | 57 +++++++++++++++++++++++++++++++++------------------------
1 files changed, 33 insertions(+), 24 deletions(-)
---
diff --git a/src/applet.c b/src/applet.c
index 59691f6..fdf2145 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -310,11 +310,12 @@ get_device_class_from_connection (NMConnection *connection, NMApplet *applet)
#if WITH_MODEM_MANAGER_1
else if (applet->mm1_running && (!strcmp (ctype, NM_SETTING_GSM_SETTING_NAME) || !strcmp (ctype,
NM_SETTING_CDMA_SETTING_NAME)))
return applet->broadband_class;
-#endif
+#else
else if (!strcmp (ctype, NM_SETTING_GSM_SETTING_NAME))
return applet->gsm_class;
else if (!strcmp (ctype, NM_SETTING_CDMA_SETTING_NAME))
return applet->cdma_class;
+#endif
else if (!strcmp (ctype, NM_SETTING_BLUETOOTH_SETTING_NAME))
return applet->bt_class;
else if (!strcmp (ctype, NM_SETTING_BOND_SETTING_NAME))
@@ -2703,37 +2704,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;
}
+}
+
+static void
+mm1_client_setup (NMApplet *applet)
+{
+ GDBusConnection *system_bus;
+ GError *error = NULL;
- 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);
+ 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]