From b601c991237fd35aafb6e70cd3c01313a0ff94b7 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 4 Aug 2016 11:44:24 -0500 Subject: [PATCH] device: Modify disconnect_cb logic Calling device_disassociated inside disconnect_cb was mostly pointless. Most attributes were already cleared by device_disconnect() when initiating the disconnection procedure. This patch also modifies the logic for triggering the autoconnect. If the user initiated the disconnect call, then autoconnect should not be triggered. If the disconnect was triggered by other means, then iwd will still enter autoconnect mode. --- src/device.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index e854adbb..671fee27 100644 --- a/src/device.c +++ b/src/device.c @@ -774,6 +774,7 @@ static void device_disconnect_cb(struct netdev *netdev, bool success, void *user_data) { struct device *device = user_data; + bool trigger_autoconnect = true; l_debug("%d, success: %d", device->index, success); @@ -789,9 +790,19 @@ static void device_disconnect_cb(struct netdev *netdev, bool success, dbus_pending_reply(&device->disconnect_pending, reply); + + /* + * If the disconnect was triggered by the user, don't + * autoconnect. Wait for user's explicit instructions to scan + * and connect to the network + */ + trigger_autoconnect = false; } - device_disassociated(device); + device_enter_state(device, DEVICE_STATE_DISCONNECTED); + + if (trigger_autoconnect) + device_enter_state(device, DEVICE_STATE_AUTOCONNECT); } int device_disconnect(struct device *device)