Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ] bearer: Fix Connect refused as in progress after a failed attempt
@ 2026-11-10  8:03 Kevin Dewald
  2026-11-10 12:14 ` [BlueZ] " bluez.test.bot
  2026-11-10 16:40 ` [PATCH BlueZ] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Kevin Dewald @ 2026-11-10  8:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Luiz Augusto von Dentz, Kevin Dewald

Connect keeps the method call in bearer->connect before starting the
connection, and releases it when the connection completes or fails.
When the connection cannot even be started, as when the adapter is
powered off, the call is answered with an error right away but stays
in bearer->connect. Every later Connect on that bearer is then refused
with org.bluez.Error.InProgress, until the device connects some other
way.

Keep the call only once the connection has been started, as
Device1.Connect does.

Fixes: 4e21ebcaa5d0 ("bearer: Implement Connect/Disconnect methods")
Assisted-by: Claude:claude-opus-5.5
---
I reproduced this with a functional test on master and bluetooth-next
3f425f95ba39: host0 pairs with host1, disconnects, powers its adapter
off and calls Connect, which fails, then powers it on and calls Connect
again:

  Second Connect   master                       with the patch
  Device1 (LE)     connected                    connected
  Bearer.LE1       org.bluez.Error.InProgress   connected
  Bearer.BREDR1    org.bluez.Error.InProgress   connected

The test_bearer.py tests and the rest of the functional tests pass as
before. I can send the test as a patch for test_bearer.py if you want
it.

 src/bearer.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/bearer.c b/src/bearer.c
index e11a844d8..ebcdc2b4c 100644
--- a/src/bearer.c
+++ b/src/bearer.c
@@ -124,6 +124,7 @@ static DBusMessage *bearer_connect(DBusConnection *conn, DBusMessage *msg,
 {
 	struct btd_bearer *bearer = user_data;
 	struct btd_device *device = bearer->device;
+	DBusMessage *reply;
 	int err;
 
 	if (btd_device_bdaddr_type_connected(device, bearer->type)) {
@@ -145,13 +146,12 @@ static DBusMessage *bearer_connect(DBusConnection *conn, DBusMessage *msg,
 		return NULL;
 	}
 
-	if (msg)
-		bearer->connect = dbus_message_ref(msg);
-
-	if (bearer->type == BDADDR_BREDR)
-		return device_connect_profiles(device, BDADDR_BREDR,
-								msg, NULL);
-	else {
+	if (bearer->type == BDADDR_BREDR) {
+		reply = device_connect_profiles(device, BDADDR_BREDR, msg,
+									NULL);
+		if (reply)
+			return reply;
+	} else {
 		btd_device_set_temporary(device, false);
 		device_resume_auto_connect(device);
 		err = device_connect_le(device);
@@ -159,6 +159,9 @@ static DBusMessage *bearer_connect(DBusConnection *conn, DBusMessage *msg,
 			return btd_error_failed(msg, strerror(-err));
 	}
 
+	if (msg)
+		bearer->connect = dbus_message_ref(msg);
+
 	return NULL;
 }
 

base-commit: 77afa9ee44ed865ada65e1047f7fe4b0a7be375e
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-10 16:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10  8:03 [PATCH BlueZ] bearer: Fix Connect refused as in progress after a failed attempt Kevin Dewald
2026-11-10 12:14 ` [BlueZ] " bluez.test.bot
2026-11-10 16:40 ` [PATCH BlueZ] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox