mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-12-12 21:44:12 +08:00
core: Do not attempt to connect if adapter is not powered
If the adapter is not yet powered do not attempt to connect, also abort any connection attempt in case of error -EHOSTUNREACH is returned by the kernel which also means the adapter is not up or in case of -ECONNABORTED which means the adapter was powered down during the connection attempt.
This commit is contained in:
parent
fa0ce2cbb4
commit
ea03e79796
14
src/device.c
14
src/device.c
@ -1156,8 +1156,15 @@ static void device_profile_connected(struct btd_device *dev,
|
||||
if (dev->pending == NULL)
|
||||
return;
|
||||
|
||||
if (!dev->connected && err == -EHOSTDOWN)
|
||||
goto done;
|
||||
if (!dev->connected) {
|
||||
switch (-err) {
|
||||
case EHOSTDOWN: /* page timeout */
|
||||
case EHOSTUNREACH: /* adapter not powered */
|
||||
case ECONNABORTED: /* adapter powered down */
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pending = dev->pending->data;
|
||||
l = find_service_with_profile(dev->pending, profile);
|
||||
@ -1297,6 +1304,9 @@ static DBusMessage *connect_profiles(struct btd_device *dev, DBusMessage *msg,
|
||||
if (dev->pending || dev->connect || dev->browse)
|
||||
return btd_error_in_progress(msg);
|
||||
|
||||
if (!btd_adapter_get_powered(dev->adapter))
|
||||
return btd_error_not_ready(msg);
|
||||
|
||||
device_set_temporary(dev, FALSE);
|
||||
|
||||
if (!dev->svc_resolved)
|
||||
|
Loading…
Reference in New Issue
Block a user