Diff between 6960cb73b272a89073c5007dbb4f2c5a29fce22e and e13cd2f762741d80dff0238177d6a179d9609a31

Changed Files

File Additions Deletions Status
src/device.c +13 -0 modified

Full Patch

diff --git a/src/device.c b/src/device.c
index 686dbfb..4320234 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1075,8 +1075,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)
@@ -1084,6 +1090,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;