All of lore.kernel.org
 help / color / mirror / Atom feed
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 2/2] adapter: Fix Discovering staying true after a failed stop
Date: Tue, 27 Oct 2026 10:19:23 -0700	[thread overview]
Message-ID: <20261027171923.82919-3-kevin@simpleble.org> (raw)
In-Reply-To: <20261027171923.82919-1-kevin@simpleble.org>

When Stop Discovery for the last client fails, for example because the
controller times out the scan disable, stop_discovery_complete()
removes the client but keeps Discovering true until the kernel reports
the discovery state. When the kernel then reports the discovery as
stopped, discovering_callback() only triggers passive scanning, as no
client is left, so Discovering stays true and the next StartDiscovery
with the same filter returns without starting a discovery.

Clear Discovering when the kernel reports the discovery as stopped and
no client is left.

Fixes: c1226f79ec97 ("adapter: Fix not checking status of stop discovery command")
Assisted-by: Claude:claude-opus-5.5
---
 src/adapter.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 4d753028a..c8889bee1 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2146,6 +2146,17 @@ static void discovering_callback(uint16_t index, uint16_t length,
 	 * passive scanning attempt.
 	 */
 	if (!adapter->discovery_list) {
+		/*
+		 * Discovering is left set when stopping the discovery of the
+		 * last client failed, so clear it once the kernel reports the
+		 * discovery as stopped.
+		 */
+		if (!adapter->discovery_enable && adapter->discovering) {
+			adapter->discovering = false;
+			g_dbus_emit_property_changed(dbus_conn, adapter->path,
+						ADAPTER_INTERFACE, "Discovering");
+		}
+
 		if (!adapter->connect_le)
 			trigger_passive_scanning(adapter);
 		return;
-- 
2.54.0 (Apple Git-157)


  parent reply	other threads:[~2026-10-27 17:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 17:19 [PATCH BlueZ 0/2] adapter: Fix Discovering staying true when stopping fails Kevin Dewald
2026-10-27 17:19 ` [PATCH BlueZ 1/2] adapter: Fix Discovering staying true after a rejected stop Kevin Dewald
2026-10-27 20:29   ` adapter: Fix Discovering staying true when stopping fails bluez.test.bot
2026-10-27 17:19 ` Kevin Dewald [this message]
2026-10-28 19:50 ` [PATCH BlueZ 0/2] " 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=20261027171923.82919-3-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.