Skip to contentSkip to conversation

core: Fix calling profile .connect multiple times

PATCH Applied Luiz Augusto von Dentz 2 participants 2 messages Feb 8, 2013 – Feb 15, 2013 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 core: Fix calling profile .connect multiple times

From: Luiz Augusto von Dentz <[email protected]>

Sometimes profiles may complete the connection in different order than expected so the code has to check if it was actually the current pending profile to proceed to the next.

---
 src/device.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
src/device.c +13 -0
index 49f8957..8ee7659 100644
@@ -1085,8 +1085,14 @@ static int connect_next(struct btd_device *dev)
 void device_profile_connected(struct btd_device *dev,
 					struct btd_profile *profile, int err)
 {
+	struct btd_profile *pending;
+
 	DBG("%s %s (%d)", profile->name, strerror(-err), -err);
 
+	if (dev->pending == NULL)
+		return;
+
+	pending = dev->pending->data;
 	dev->pending = g_slist_remove(dev->pending, profile);
 
 	if (!err)
@@ -1094,6 +1100,13 @@ void device_profile_connected(struct btd_device *dev,
 				g_slist_append(dev->connected_profiles,
 								profile);
 
+	/* Only continue connecting the next profile if it matches the first
+	 * pending, otherwise it will trigger another connect to the same
+	 * profile
+	 */
+	if (profile != pending)
+		return;
+
 	if (connect_next(dev) == 0)
 		return;
 
Signature · 1 line
1.8.1
#1 lore raw

Hi Luiz,

Quoted 6 lines · Luiz Augusto von Dentz

Sometimes profiles may complete the connection in different order than expected so the code has to check if it was actually the current pending profile to proceed to the next.

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

Applied. Thanks.

Johan