device: Fix rare ERR_BREDR_CONN_BUSY during connect
cover device: Fix rare ERR_BREDR_CONN_BUSY during connect
Hello everyone,
While experimenting with a device acting as and A2DP Source, I have encountered the following very rare case during connection to an external speaker:
1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/sink.c:sink_set_state() State changed /org/bluez/hci0/dev_28_2B_B9_40_00_1B: SINK_STATE_CONNECTING -> SINK_STATE_DISCONNECTED 1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_unref() 0x17c1350: ref=1 1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/a2dp.c:channel_remove() chan 0x17ac468 1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_unref() 0x17c1350: ref=0 1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_free() 0x17c1350 1970-01-01 00:37:50 debug bluetoothd[240]: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000c 1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:dev_disconnected() Device 28:2B:B9:40:00:1B disconnected, reason 2 1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:adapter_remove_connection() 1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_remove_connection() connection removed while Connect() is waiting reply 1970-01-01 00:37:50 debug bluetoothd[240]: plugins/policy.c:disconnect_cb() reason 2 1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 28:2B:B9:40:00:1B type 0 status 0xe 1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e 1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_bonding_failed() status 14
Subsequent attempts to connect using bluetoothctl lead to "br-connection-busy":
[bluetooth]# connect 28:2B:B9:40:00:1B
Attempting to connect to 28:2B:B9:40:00:1B
Failed to connect: org.bluez.Error.InProgress br-connection-busy
The reason is that "connect_profiles" does the following check:
if (dev->pending || dev->connect || dev->browse)
return btd_error_in_progress_str(msg, ERR_BREDR_CONN_BUSY);
In the above scenario, "dev->pending" is not NULL. I have prepared the RFC patch that frees it when a disconnect occurs in the "device_remove_connection" code path. I'm not sure if this is the correct way to solve the issue, but with this patch it can no longer be reproduced.
Oleg Lyovin (1):
device: Fix rare ERR_BREDR_CONN_BUSY during connect
src/device.c | 4 ++++ 1 file changed, 4 insertions(+)
Signature · 1 line
2.34.1
PATCH 1/1 device: Fix rare ERR_BREDR_CONN_BUSY during connect
Disconnect may happen while the connection to the device is not finished, leading to device->pending list is not being freed. As a result, subsequent connection attempts leads to ERR_BREDR_CONN_BUSY error, making it impossible to establish a connection.
This patch frees device->pending list in such case.
--- src/device.c | 4 ++++ 1 file changed, 4 insertions(+)
src/device.c +4 -0
@@ -1907,6 +1907,10 @@ void device_request_disconnect(struct btd_device *device, DBusMessage *msg)g_dbus_send_message (dbus_conn, reply);dbus_message_unref (device->connect); device->connect =NULL ; + +/* Connection does not exists anymore, so free pending services */ +g_slist_free (device->pending); + device->pending =NULL ; }if (btd_device_is_connected (device) && msg)
Signature · 1 line
2.34.1
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=953043
---Test result---
Test Summary:
CheckPatch PENDING 0.25 seconds GitLint PENDING 0.24 seconds BuildEll PASS 20.35 seconds BluezMake PASS 2594.14 seconds MakeCheck PASS 20.22 seconds MakeDistcheck PASS 196.59 seconds CheckValgrind PASS 273.29 seconds CheckSmatch PASS 300.77 seconds bluezmakeextell PASS 128.38 seconds IncrementalBuild PENDING 0.30 seconds ScanBuild PASS 892.02 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=953043
---Test result---
Test Summary:
CheckPatch PENDING 0.32 seconds GitLint PENDING 0.23 seconds BuildEll PASS 20.85 seconds BluezMake PASS 2833.99 seconds MakeCheck PASS 20.23 seconds MakeDistcheck PASS 202.74 seconds CheckValgrind PASS 280.88 seconds CheckSmatch PASS 308.50 seconds bluezmakeextell PASS 130.29 seconds IncrementalBuild PENDING 0.31 seconds ScanBuild PASS 920.66 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
Gently reminder, please check the patch.
Quoted 42 lines · Oleg Lyovin
Hello everyone,
While experimenting with a device acting as and A2DP Source, I have encountered the following very rare case during connection to an external speaker:
1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/sink.c:sink_set_state() State changed /org/bluez/hci0/dev_28_2B_B9_40_00_1B: SINK_STATE_CONNECTING -> SINK_STATE_DISCONNECTED 1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_unref() 0x17c1350: ref=1 1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/a2dp.c:channel_remove() chan 0x17ac468 1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_unref() 0x17c1350: ref=0 1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_free() 0x17c1350 1970-01-01 00:37:50 debug bluetoothd[240]: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000c 1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:dev_disconnected() Device 28:2B:B9:40:00:1B disconnected, reason 2 1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:adapter_remove_connection() 1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_remove_connection() connection removed while Connect() is waiting reply 1970-01-01 00:37:50 debug bluetoothd[240]: plugins/policy.c:disconnect_cb() reason 2 1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 28:2B:B9:40:00:1B type 0 status 0xe 1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e 1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_bonding_failed() status 14Subsequent attempts to connect using bluetoothctl lead to "br-connection-busy":
[bluetooth]# connect 28:2B:B9:40:00:1B
Attempting to connect to 28:2B:B9:40:00:1B
Failed to connect: org.bluez.Error.InProgress br-connection-busyThe reason is that "
connect_profiles" does the following check:
if (dev->pending||dev->connect||dev->browse)return btd_error_in_progress_str(msg, ERR_BREDR_CONN_BUSY);In the above scenario, "
dev->pending" is not NULL. I have prepared the RFC patch that frees it when a disconnect occurs in the "device_remove_connection" code path. I'm not sure if this is the correct way to solve the issue, but with this patch it can no longer be reproduced.Oleg Lyovin (1):
device: Fix rareERR_BREDR_CONN_BUSYduring connectsrc/device.c | 4 ++++ 1 file changed, 4 insertions(+)
Gently reminder, please check the patch.
Quoted 42 lines · Oleg Lyovin
Hello everyone,
While experimenting with a device acting as and A2DP Source, I have encountered the following very rare case during connection to an external speaker:
1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/sink.c:sink_set_state() State changed /org/bluez/hci0/dev_28_2B_B9_40_00_1B: SINK_STATE_CONNECTING -> SINK_STATE_DISCONNECTED 1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_unref() 0x17c1350: ref=1 1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/a2dp.c:channel_remove() chan 0x17ac468 1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_unref() 0x17c1350: ref=0 1970-01-01 00:37:47 debug bluetoothd[240]: profiles/audio/avdtp.c:avdtp_free() 0x17c1350 1970-01-01 00:37:50 debug bluetoothd[240]: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000c 1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:dev_disconnected() Device 28:2B:B9:40:00:1B disconnected, reason 2 1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:adapter_remove_connection() 1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_remove_connection() connection removed while Connect() is waiting reply 1970-01-01 00:37:50 debug bluetoothd[240]: plugins/policy.c:disconnect_cb() reason 2 1970-01-01 00:37:50 debug bluetoothd[240]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 28:2B:B9:40:00:1B type 0 status 0xe 1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e 1970-01-01 00:37:50 debug bluetoothd[240]: src/device.c:device_bonding_failed() status 14Subsequent attempts to connect using bluetoothctl lead to "br-connection-busy":
[bluetooth]# connect 28:2B:B9:40:00:1B
Attempting to connect to 28:2B:B9:40:00:1B
Failed to connect: org.bluez.Error.InProgress br-connection-busyThe reason is that "
connect_profiles" does the following check:
if (dev->pending||dev->connect||dev->browse)return btd_error_in_progress_str(msg, ERR_BREDR_CONN_BUSY);In the above scenario, "
dev->pending" is not NULL. I have prepared the RFC patch that frees it when a disconnect occurs in the "device_remove_connection" code path. I'm not sure if this is the correct way to solve the issue, but with this patch it can no longer be reproduced.Oleg Lyovin (1):
device: Fix rareERR_BREDR_CONN_BUSYduring connectsrc/device.c | 4 ++++ 1 file changed, 4 insertions(+)