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.

(cherry picked from commit 063f9185b9)
This commit is contained in:
Thomas Haller 2016-01-19 22:00:53 +01:00
parent 7944c5f8ac
commit dd6239bdf6
3 changed files with 24 additions and 29 deletions

View file

@ -1252,8 +1252,7 @@ NMSupplicantInterface *
nm_supplicant_interface_new (const char *ifname,
gboolean is_wireless,
gboolean fast_supported,
ApSupport ap_support,
gboolean start_now)
ApSupport ap_support)
{
NMSupplicantInterface *self;
NMSupplicantInterfacePrivate *priv;
@ -1268,9 +1267,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;
}

View file

@ -122,8 +122,7 @@ GType nm_supplicant_interface_get_type (void);
NMSupplicantInterface * nm_supplicant_interface_new (const char *ifname,
gboolean is_wireless,
gboolean fast_supported,
ApSupport ap_support,
gboolean start_now);
ApSupport ap_support);
void nm_supplicant_interface_set_supplicant_available (NMSupplicantInterface *self,
gboolean available);

View file

@ -58,6 +58,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,
@ -65,7 +76,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);
@ -74,22 +84,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_supplicant_manager_iface_get() and release() implements no form of ref-counting
* to properly handle reusing a cached instance. It's also unclear whether that is
@ -205,16 +215,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)
{