Diff between 4cc7c23afb3377baca418b2a5b6a3ebd58d570c0 and 35ac5407a758cdeeeb23182a8d08d57c5ca50cbc

Changed Files

File Additions Deletions Status
src/adapter.c +16 -0 modified

Full Patch

diff --git a/src/adapter.c b/src/adapter.c
index 9141773..afe1ff7 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2732,6 +2732,14 @@ const char *btd_adapter_get_name(struct btd_adapter *adapter)
 int adapter_connect_list_add(struct btd_adapter *adapter,
 					struct btd_device *device)
 {
+	/*
+	 * If the adapter->connect_le device is getting added back to
+	 * the connect list it probably means that the connect attempt
+	 * failed and hence we should clear this pointer
+	 */
+	if (device == adapter->connect_le)
+		adapter->connect_le = NULL;
+
 	if (g_slist_find(adapter->connect_list, device)) {
 		DBG("ignoring already added device %s",
 						device_get_path(device));
@@ -2759,6 +2767,14 @@ int adapter_connect_list_add(struct btd_adapter *adapter,
 void adapter_connect_list_remove(struct btd_adapter *adapter,
 					struct btd_device *device)
 {
+	/*
+	 * If the adapter->connect_le device is being removed from the
+	 * connect list it means the connection was successful and hence
+	 * the pointer should be cleared
+	 */
+	if (device == adapter->connect_le)
+		adapter->connect_le = NULL;
+
 	if (!g_slist_find(adapter->connect_list, device)) {
 		DBG("device %s is not on the list, ignoring",
 						device_get_path(device));