public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [BlueZ PATCH v1] device: Reply to connect request if SDP search failed
@ 2021-04-19 23:36 Miao-chen Chou
  2021-04-20  0:03 ` [BlueZ,v1] " bluez.test.bot
  0 siblings, 1 reply; 3+ messages in thread
From: Miao-chen Chou @ 2021-04-19 23:36 UTC (permalink / raw)
  To: Bluetooth Kernel Mailing List
  Cc: Alain Michaud, Sonny Sasaka, Marcel Holtmann,
	Luiz Augusto von Dentz, Miao-chen Chou

SDP request can be initiated during BR/EDR connection. This fixes a
missing reply to the method call to prevent generic error message for
no reply.

The following test steps were performed:
(1) Put Bose QC35 into pairing mode, start scanning on bluetoothctl
(2) Turn off the headphones and connect to the headphones
(3) Verify that error should returns immediately to bluetoothctl
---

 src/device.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/device.c b/src/device.c
index df440ce09..516ffe2e7 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4966,6 +4966,7 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
 {
 	struct browse_req *req = user_data;
 	struct btd_device *device = req->device;
+	DBusMessage *reply;
 	GSList *primaries;
 	char addr[18];
 
@@ -5009,6 +5010,18 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
 						DEVICE_INTERFACE, "UUIDs");
 
 send_reply:
+	/* If SDP search failed during an ongoing connection request, we should
+	 * reply to D-Bus method call.
+	 */
+	if (err < 0 && device->connect) {
+		DBG("SDP failed during connection");
+		reply = btd_error_failed(device->connect,
+						strerror(-err));
+		g_dbus_send_message(dbus_conn, reply);
+		dbus_message_unref(device->connect);
+		device->connect = NULL;
+	}
+
 	device_svc_resolved(device, BROWSE_SDP, BDADDR_BREDR, err);
 }
 
-- 
2.31.1.368.gbe11c130af-goog


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

end of thread, other threads:[~2021-04-21  0:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-19 23:36 [BlueZ PATCH v1] device: Reply to connect request if SDP search failed Miao-chen Chou
2021-04-20  0:03 ` [BlueZ,v1] " bluez.test.bot
2021-04-21  0:01   ` Luiz Augusto von Dentz

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