wifi/iwd: always update can_connect in state_changed

Ensure priv->can_connect is up to date on IWD state changed.  If we
exited the function early priv->can_connect would sometimes be wrongly
TRUE and we'd start a new autoconnect too early after IP configuration
had failed for example.
This commit is contained in:
Andrew Zaborowski 2018-10-10 02:17:47 +02:00 committed by Thomas Haller
parent 979c632e11
commit 2fff4e14b4

View file

@ -2029,7 +2029,7 @@ state_changed (NMDeviceIwd *self, const char *new_state)
NMDevice *device = NM_DEVICE (self);
NMDeviceState dev_state = nm_device_get_state (device);
gboolean iwd_connection = FALSE;
gboolean can_connect;
gboolean can_connect = priv->can_connect;
_LOGI (LOGD_DEVICE | LOGD_WIFI, "new IWD device state is %s", new_state);
@ -2040,6 +2040,8 @@ state_changed (NMDeviceIwd *self, const char *new_state)
/* Don't allow scanning while connecting, disconnecting or roaming */
set_can_scan (self, NM_IN_STRSET (new_state, "connected", "disconnected"));
priv->can_connect = FALSE;
if (NM_IN_STRSET (new_state, "connecting", "connected", "roaming")) {
/* If we were connecting, do nothing, the confirmation of
* a connection success is handled in the Device.Connect
@ -2081,10 +2083,10 @@ state_changed (NMDeviceIwd *self, const char *new_state)
/* Don't allow new connection until iwd exits disconnecting and no
* Connect callback is pending.
*/
can_connect = NM_IN_STRSET (new_state, "disconnected");
if (can_connect != priv->can_connect) {
priv->can_connect = can_connect;
nm_device_emit_recheck_auto_activate (device);
if (NM_IN_STRSET (new_state, "disconnected")) {
priv->can_connect = TRUE;
if (!can_connect)
nm_device_emit_recheck_auto_activate (device);
}
}