From: Luiz Augusto von Dentz Date: Wed, 8 Jul 2020 21:14:59 +0000 (-0700) Subject: adapter: Fix not cleanup temporary devices X-Git-Tag: submit/tizen/20210606.232858~47 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b0c0731ebc47dbde0253fa84984229abb971acb;p=platform%2Fupstream%2Fbluez.git adapter: Fix not cleanup temporary devices 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 Signed-off-by: Ayush Garg --- diff --git a/src/adapter.c b/src/adapter.c index d522a094..07572376 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -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;