adapter: Fix not cleanup temporary devices
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 8 Jul 2020 21:14:59 +0000 (14:14 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:49 +0000 (14:30 +0530)
When an adapter is powered down or unplugged remove its temporary
devices immediatelly as the application will no longer be able to
connect to them.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/adapter.c

index d522a094e9855c0e12f19d9f0cb11146cd049e11..075723765a14dde7f6228227e7ee6db8bbfd0832 100644 (file)
@@ -2050,7 +2050,7 @@ static gboolean remove_temp_devices(gpointer user_data)
        return FALSE;
 }
 
-static void discovery_cleanup(struct btd_adapter *adapter)
+static void discovery_cleanup(struct btd_adapter *adapter, int timeout)
 {
        GSList *l, *next;
 
@@ -2088,7 +2088,7 @@ static void discovery_cleanup(struct btd_adapter *adapter)
 
        }
 
-       adapter->temp_devices_timeout = g_timeout_add_seconds(TEMP_DEV_TIMEOUT,
+       adapter->temp_devices_timeout = g_timeout_add_seconds(timeout,
                                                remove_temp_devices, adapter);
 }
 
@@ -2151,7 +2151,7 @@ static void discovery_remove(struct discovery_client *client)
        if (adapter->discovery_list)
                return;
 
-       discovery_cleanup(adapter);
+       discovery_cleanup(adapter, TEMP_DEV_TIMEOUT);
 }
 
 static void trigger_start_discovery(struct btd_adapter *adapter, guint delay);
@@ -3191,7 +3191,7 @@ static void discovery_destroy(void *user_data)
                adapter->temp_devices_timeout = 0;
        }
 
-       discovery_cleanup(adapter);
+       discovery_cleanup(adapter, 0);
 
        adapter->temp_devices_timeout = g_timeout_add_seconds(TEMP_DEV_TIMEOUT,
                                                remove_temp_devices, adapter);
@@ -3274,7 +3274,7 @@ static void le_discovery_destroy(void *user_data)
                adapter->temp_devices_timeout = 0;
        }
 
-       discovery_cleanup(adapter);
+       discovery_cleanup(adapter, 0);
 }
 
 static void le_discovery_disconnect(DBusConnection *conn, void *user_data)
@@ -11427,7 +11427,7 @@ static void adapter_remove(struct btd_adapter *adapter)
                adapter->temp_devices_timeout = 0;
        }
 
-       discovery_cleanup(adapter);
+       discovery_cleanup(adapter, 0);
 
        g_slist_free(adapter->connect_list);
        adapter->connect_list = NULL;
@@ -11438,7 +11438,7 @@ static void adapter_remove(struct btd_adapter *adapter)
        g_slist_free(adapter->devices);
        adapter->devices = NULL;
 
-       discovery_cleanup(adapter);
+       discovery_cleanup(adapter, 0);
 
        unload_drivers(adapter);
 
@@ -12177,7 +12177,7 @@ static void adapter_stop(struct btd_adapter *adapter)
        g_slist_free_full(adapter->discovery_list, discovery_free);
        adapter->discovery_list = NULL;
 
-       discovery_cleanup(adapter);
+       discovery_cleanup(adapter, 0);
 
        adapter->filtered_discovery = false;
        adapter->no_scan_restart_delay = false;