device: Simplify reply logic in device_connect_cb
Also, remove the check for device->state == DEVICE_STATE_CONNECTING. device_connect_cb should always called when the state is CONNECTING. If this is not so, it indicates a bug inside the netdev layer.
This commit is contained in:
parent
f4201d06c2
commit
d95f9a29c5
34
src/device.c
34
src/device.c
|
@ -582,33 +582,31 @@ static void device_connect_cb(struct netdev *netdev, enum netdev_result result,
|
||||||
{
|
{
|
||||||
struct device *device = user_data;
|
struct device *device = user_data;
|
||||||
|
|
||||||
if (result != NETDEV_RESULT_OK) {
|
if (device->connect_pending) {
|
||||||
struct l_dbus_message *reply;
|
struct l_dbus_message *reply;
|
||||||
|
|
||||||
if (device->connect_pending) {
|
switch (result) {
|
||||||
if (result == NETDEV_RESULT_ABORTED)
|
case NETDEV_RESULT_ABORTED:
|
||||||
reply = dbus_error_aborted(device->connect_pending);
|
reply = dbus_error_aborted(device->connect_pending);
|
||||||
else
|
break;
|
||||||
reply = dbus_error_failed(device->connect_pending);
|
case NETDEV_RESULT_OK:
|
||||||
|
|
||||||
dbus_pending_reply(&device->connect_pending, reply);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (device->state == DEVICE_STATE_CONNECTING)
|
|
||||||
device_disassociated(device);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (device->connect_pending) {
|
|
||||||
struct l_dbus_message *reply;
|
|
||||||
|
|
||||||
reply = l_dbus_message_new_method_return(
|
reply = l_dbus_message_new_method_return(
|
||||||
device->connect_pending);
|
device->connect_pending);
|
||||||
l_dbus_message_set_arguments(reply, "");
|
l_dbus_message_set_arguments(reply, "");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
reply = dbus_error_failed(device->connect_pending);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
dbus_pending_reply(&device->connect_pending, reply);
|
dbus_pending_reply(&device->connect_pending, reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result != NETDEV_RESULT_OK) {
|
||||||
|
device_disassociated(device);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
network_connected(device->connected_network);
|
network_connected(device->connected_network);
|
||||||
device_enter_state(device, DEVICE_STATE_CONNECTED);
|
device_enter_state(device, DEVICE_STATE_CONNECTED);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue