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.
This commit is contained in:
Thomas Haller 2016-01-19 22:00:53 +01:00
parent 5d64da1da2
commit 063f9185b9
3 changed files with 24 additions and 29 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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)
{