public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] adapter: Cancel the service authorization when remote is disconnected
@ 2024-08-26  9:00 Cheng Jiang
  2024-08-26 10:43 ` [v2] " bluez.test.bot
  2024-08-26 13:43 ` [PATCH v2] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 6+ messages in thread
From: Cheng Jiang @ 2024-08-26  9:00 UTC (permalink / raw)
  To: linux-bluetooth

If the remote device drops the connection before DUT confirm the
service authorization, the DUT still must wait for service
authorization timeout before processing future request.

Cancel the service authorization request when connection is dropped.
---
 src/adapter.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 245de4456..3ad000425 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -8502,6 +8502,25 @@ static void disconnect_notify(struct btd_device *dev, uint8_t reason)
 	}
 }
 
+static void adapter_cancel_service_auth(struct btd_adapter *adapter,
+					struct btd_device *device)
+{
+	struct service_auth *auth;
+	GList *l;
+
+	auth = NULL;
+	for (l = adapter->auths->head; l != NULL; l = l->next) {
+		auth = l->data;
+		if (auth->device == device)
+			break;
+	}
+	if (auth != NULL) {
+		DBG("Cancel pending auth: %s", auth->uuid);
+		g_queue_remove(auth->adapter->auths, auth);
+		service_auth_cancel(auth);
+	}
+}
+
 static void dev_disconnected(struct btd_adapter *adapter,
 					const struct mgmt_addr_info *addr,
 					uint8_t reason)
@@ -8516,6 +8535,7 @@ static void dev_disconnected(struct btd_adapter *adapter,
 	device = btd_adapter_find_device(adapter, &addr->bdaddr, addr->type);
 	if (device) {
 		adapter_remove_connection(adapter, device, addr->type);
+		adapter_cancel_service_auth(adapter, device);
 		disconnect_notify(device, reason);
 	}
 
-- 
2.25.1


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

end of thread, other threads:[~2024-09-20  1:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-26  9:00 [PATCH v2] adapter: Cancel the service authorization when remote is disconnected Cheng Jiang
2024-08-26 10:43 ` [v2] " bluez.test.bot
2024-08-26 13:43 ` [PATCH v2] " Luiz Augusto von Dentz
2024-08-26 14:30   ` Cheng Jiang
2024-09-19 19:53     ` Luiz Augusto von Dentz
2024-09-20  1:56       ` Cheng Jiang

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