device: Reset connected_network when disconnect operation starts
It is probably rare that a disconnect should fail but if it happens the device->state is not returned to CONNECTED and I'm not sure if it should be, so the ConnectedNetwork property and other bits should probably be reset at the start of the disconnection instead of at the end. Also check if state is CONNECTED before calling network_disconnected because network_connected may have not been called yet.
This commit is contained in:
parent
e76daf224c
commit
8f0d68139e
42
src/device.c
42
src/device.c
|
@ -500,20 +500,21 @@ void device_disassociated(struct device *device)
|
||||||
struct network *network = device->connected_network;
|
struct network *network = device->connected_network;
|
||||||
struct l_dbus *dbus = dbus_get_bus();
|
struct l_dbus *dbus = dbus_get_bus();
|
||||||
|
|
||||||
if (!network)
|
if (network) {
|
||||||
return;
|
if (device->state == DEVICE_STATE_CONNECTED)
|
||||||
|
network_disconnected(network);
|
||||||
|
|
||||||
network_disconnected(network);
|
device->connected_bss = NULL;
|
||||||
|
device->connected_network = NULL;
|
||||||
|
|
||||||
device->connected_bss = NULL;
|
l_dbus_property_changed(dbus, device_get_path(device),
|
||||||
device->connected_network = NULL;
|
IWD_DEVICE_INTERFACE,
|
||||||
|
"ConnectedNetwork");
|
||||||
|
l_dbus_property_changed(dbus, network_get_path(network),
|
||||||
|
IWD_NETWORK_INTERFACE, "Connected");
|
||||||
|
}
|
||||||
|
|
||||||
device_enter_state(device, DEVICE_STATE_AUTOCONNECT);
|
device_enter_state(device, DEVICE_STATE_AUTOCONNECT);
|
||||||
|
|
||||||
l_dbus_property_changed(dbus, device_get_path(device),
|
|
||||||
IWD_DEVICE_INTERFACE, "ConnectedNetwork");
|
|
||||||
l_dbus_property_changed(dbus, network_get_path(network),
|
|
||||||
IWD_NETWORK_INTERFACE, "Connected");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void device_lost_beacon(struct device *device)
|
static void device_lost_beacon(struct device *device)
|
||||||
|
@ -742,8 +743,7 @@ static struct l_dbus_message *device_disconnect(struct l_dbus *dbus,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
struct device *device = user_data;
|
struct device *device = user_data;
|
||||||
|
struct network *network;
|
||||||
l_debug("");
|
|
||||||
|
|
||||||
if (device->state == DEVICE_STATE_CONNECTING ||
|
if (device->state == DEVICE_STATE_CONNECTING ||
|
||||||
device->state == DEVICE_STATE_DISCONNECTING)
|
device->state == DEVICE_STATE_DISCONNECTING)
|
||||||
|
@ -755,6 +755,24 @@ static struct l_dbus_message *device_disconnect(struct l_dbus *dbus,
|
||||||
if (netdev_disconnect(device->netdev, device_disconnect_cb, device) < 0)
|
if (netdev_disconnect(device->netdev, device_disconnect_cb, device) < 0)
|
||||||
return dbus_error_failed(message);
|
return dbus_error_failed(message);
|
||||||
|
|
||||||
|
network = device->connected_network;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the disconnect somehow fails we won't know if we're still
|
||||||
|
* connected so we may as well indicate now that we're no longer
|
||||||
|
* connected.
|
||||||
|
*/
|
||||||
|
if (device->state == DEVICE_STATE_CONNECTED)
|
||||||
|
network_disconnected(network);
|
||||||
|
|
||||||
|
device->connected_bss = NULL;
|
||||||
|
device->connected_network = NULL;
|
||||||
|
|
||||||
|
l_dbus_property_changed(dbus, device_get_path(device),
|
||||||
|
IWD_DEVICE_INTERFACE, "ConnectedNetwork");
|
||||||
|
l_dbus_property_changed(dbus, network_get_path(network),
|
||||||
|
IWD_NETWORK_INTERFACE, "Connected");
|
||||||
|
|
||||||
device_enter_state(device, DEVICE_STATE_DISCONNECTING);
|
device_enter_state(device, DEVICE_STATE_DISCONNECTING);
|
||||||
|
|
||||||
device->disconnect_pending = l_dbus_message_ref(message);
|
device->disconnect_pending = l_dbus_message_ref(message);
|
||||||
|
|
Loading…
Reference in New Issue