From a08dd2c39d14ce933e1adb3cf0377e84ca84925e Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 7 Dec 2010 13:58:49 -0600 Subject: [PATCH] supplicant: fix handling when supplicant cannot be service activated If the supplicant cannot be service activated, wait until it shows up on the bus instead of sitting around doing nothing. This fixes a small regression introduced when the _READY state was added to the supplicant interface object. --- .../nm-supplicant-interface.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/supplicant-manager/nm-supplicant-interface.c b/src/supplicant-manager/nm-supplicant-interface.c index a92268c3d..777d46abe 100644 --- a/src/supplicant-manager/nm-supplicant-interface.c +++ b/src/supplicant-manager/nm-supplicant-interface.c @@ -287,8 +287,8 @@ set_state (NMSupplicantInterface *self, guint32 new_state) /* DOWN is a terminal state */ g_return_if_fail (priv->state != NM_SUPPLICANT_INTERFACE_STATE_DOWN); - /* Cannot regress to READY or INIT from higher states */ - if (priv->state <= NM_SUPPLICANT_INTERFACE_STATE_READY) + /* Cannot regress to READY, STARTING, or INIT from higher states */ + if (priv->state >= NM_SUPPLICANT_INTERFACE_STATE_READY) g_return_if_fail (new_state > priv->state); if (new_state == NM_SUPPLICANT_INTERFACE_STATE_DOWN) { @@ -504,9 +504,10 @@ interface_get_cb (DBusGProxy *proxy, G_TYPE_INVALID)) { interface_add_done (info->interface, path); } else { - nm_log_err (LOGD_SUPPLICANT, "(%s): error adding interface: %s", + nm_log_err (LOGD_SUPPLICANT, "(%s): error getting interface: %s", priv->dev, error->message); g_clear_error (&error); + set_state (info->interface, NM_SUPPLICANT_INTERFACE_STATE_DOWN); } } @@ -545,9 +546,19 @@ interface_add_cb (DBusGProxy *proxy, if (dbus_g_error_has_name (error, WPAS_ERROR_EXISTS_ERROR)) { /* Interface already added, just get its object path */ interface_get (info->interface); + } else if ( g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN) + || dbus_g_error_has_name (error, DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND)) { + /* Supplicant wasn't running and could be launched via service + * activation. Wait for it to start by moving back to the INIT + * state. + */ + nm_log_dbg (LOGD_SUPPLICANT, "(%s): failed to activate supplicant: %s", + priv->dev, error->message); + set_state (info->interface, NM_SUPPLICANT_INTERFACE_STATE_INIT); } else { nm_log_err (LOGD_SUPPLICANT, "(%s): error adding interface: %s", priv->dev, error->message); + set_state (info->interface, NM_SUPPLICANT_INTERFACE_STATE_DOWN); } g_clear_error (&error); }