From 063f9185b95336c269c2b32484e2f6aeaae85d11 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 19 Jan 2016 22:00:53 +0100 Subject: [PATCH] supplicant: don't pass start_now argument to nm_supplicant_interface_new() Also, don't only consider the @die_count whether to start the supplicant, but check for is_available() -- which already considers @die_count and @running. --- .../nm-supplicant-interface.c | 6 +-- .../nm-supplicant-interface.h | 3 +- .../nm-supplicant-manager.c | 44 +++++++++---------- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/supplicant-manager/nm-supplicant-interface.c b/src/supplicant-manager/nm-supplicant-interface.c index d49cb4e7ee..fedcf2d24f 100644 --- a/src/supplicant-manager/nm-supplicant-interface.c +++ b/src/supplicant-manager/nm-supplicant-interface.c @@ -1425,8 +1425,7 @@ NMSupplicantInterface * nm_supplicant_interface_new (const char *ifname, gboolean is_wireless, gboolean fast_supported, - NMSupplicantFeature ap_support, - gboolean start_now) + NMSupplicantFeature ap_support) { NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; @@ -1441,9 +1440,6 @@ nm_supplicant_interface_new (const char *ifname, priv->fast_supported = fast_supported; priv->ap_support = ap_support; - if (start_now) - interface_add (self); - return self; } diff --git a/src/supplicant-manager/nm-supplicant-interface.h b/src/supplicant-manager/nm-supplicant-interface.h index d0063d1f47..7f48566330 100644 --- a/src/supplicant-manager/nm-supplicant-interface.h +++ b/src/supplicant-manager/nm-supplicant-interface.h @@ -119,8 +119,7 @@ GType nm_supplicant_interface_get_type (void); NMSupplicantInterface * nm_supplicant_interface_new (const char *ifname, gboolean is_wireless, gboolean fast_supported, - NMSupplicantFeature ap_support, - gboolean start_now); + NMSupplicantFeature ap_support); void nm_supplicant_interface_set_supplicant_available (NMSupplicantInterface *self, gboolean available); diff --git a/src/supplicant-manager/nm-supplicant-manager.c b/src/supplicant-manager/nm-supplicant-manager.c index 776bef9344..ac2b1fb867 100644 --- a/src/supplicant-manager/nm-supplicant-manager.c +++ b/src/supplicant-manager/nm-supplicant-manager.c @@ -59,6 +59,17 @@ die_count_exceeded (guint32 count) return count > 2; } +static gboolean +is_available (NMSupplicantManager *self) +{ + NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); + + return priv->running + && !die_count_exceeded (priv->die_count); +} + +/********************************************************************/ + NMSupplicantInterface * nm_supplicant_manager_iface_get (NMSupplicantManager * self, const char *ifname, @@ -66,7 +77,6 @@ nm_supplicant_manager_iface_get (NMSupplicantManager * self, { NMSupplicantManagerPrivate *priv; NMSupplicantInterface *iface = NULL; - gboolean start_now; g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), NULL); g_return_val_if_fail (ifname != NULL, NULL); @@ -75,22 +85,22 @@ nm_supplicant_manager_iface_get (NMSupplicantManager * self, iface = g_hash_table_lookup (priv->ifaces, ifname); if (!iface) { + nm_log_dbg (LOGD_SUPPLICANT, "(%s): creating new supplicant interface", ifname); + iface = nm_supplicant_interface_new (ifname, + is_wireless, + priv->fast_supported, + priv->ap_support); + g_hash_table_insert (priv->ifaces, + (char *) nm_supplicant_interface_get_ifname (iface), + iface); + /* If we're making the supplicant take a time out for a bit, don't * let the supplicant interface start immediately, just let it hang * around in INIT state until we're ready to talk to the supplicant * again. */ - start_now = !die_count_exceeded (priv->die_count); - - nm_log_dbg (LOGD_SUPPLICANT, "(%s): creating new supplicant interface", ifname); - iface = nm_supplicant_interface_new (ifname, - is_wireless, - priv->fast_supported, - priv->ap_support, - start_now); - g_hash_table_insert (priv->ifaces, - (char *) nm_supplicant_interface_get_ifname (iface), - iface); + if (is_available (self)) + nm_supplicant_interface_set_supplicant_available (iface, TRUE); } else { nm_log_dbg (LOGD_SUPPLICANT, "(%s): returning existing supplicant interface", ifname); } @@ -203,16 +213,6 @@ availability_changed (NMSupplicantManager *self, gboolean available) g_list_free_full (ifaces, g_object_unref); } -static gboolean -is_available (NMSupplicantManager *self) -{ - g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), FALSE); - - if (die_count_exceeded (NM_SUPPLICANT_MANAGER_GET_PRIVATE (self)->die_count)) - return FALSE; - return NM_SUPPLICANT_MANAGER_GET_PRIVATE (self)->running; -} - static void set_running (NMSupplicantManager *self, gboolean now_running) {