From 35ac5407a758cdeeeb23182a8d08d57c5ca50cbc Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 29 Jan 2013 17:12:23 -0600 Subject: [PATCH] core: Fix adapter->connect_le updating in connect_list_add/remove --- src/adapter.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 9141773b7..afe1ff7ae 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)); -- 2.11.0