From: Kevin Dewald <kevin@simpleble.org>
To: linux-bluetooth@vger.kernel.org
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
Kevin Dewald <kevin@simpleble.org>
Subject: [PATCH BlueZ] bearer: Fix Connect refused as in progress after a failed attempt
Date: Tue, 10 Nov 2026 00:03:11 -0800 [thread overview]
Message-ID: <20261110080311.71913-1-kevin@simpleble.org> (raw)
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)
next reply other threads:[~2026-11-10 8:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 8:03 Kevin Dewald [this message]
2026-11-10 12:14 ` [BlueZ] bearer: Fix Connect refused as in progress after a failed attempt bluez.test.bot
2026-11-10 16:40 ` [PATCH BlueZ] " patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261110080311.71913-1-kevin@simpleble.org \
--to=kevin@simpleble.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox