From 159f81f27c353ab69b51a941c5cd87ea04aee751 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 15 Jul 2020 13:29:24 -0700 Subject: [PATCH] adapter: Remove timer for removing temporary devices Now that each temporary device object can cleanup after it has detected that it has disappeared it is no longer necessary to keep this logic as well in the adapter. Signed-off-by: Anuj Jain Signed-off-by: Ayush Garg --- src/adapter.c | 52 --------------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 07572376..bc39e6f4 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -329,7 +329,6 @@ struct btd_adapter { guint le_discovery_idle_timeout; /* timeout between le discovery runs */ #endif guint passive_scan_timeout; /* timeout between passive scans */ - guint temp_devices_timeout; /* timeout for temporary devices */ guint pairable_timeout_id; /* pairable timeout id */ guint auth_idle_id; /* Pending authorization dequeue */ @@ -2029,27 +2028,6 @@ static void invalidate_rssi_and_tx_power(gpointer a) device_set_tx_power(dev, 127); } -static gboolean remove_temp_devices(gpointer user_data) -{ - struct btd_adapter *adapter = user_data; - GSList *l, *next; - - DBG("%s", adapter->path); - - adapter->temp_devices_timeout = 0; - - for (l = adapter->devices; l != NULL; l = next) { - struct btd_device *dev = l->data; - - next = g_slist_next(l); - - if (device_is_temporary(dev) && !btd_device_is_connected(dev)) - btd_adapter_remove_device(adapter, dev); - } - - return FALSE; -} - static void discovery_cleanup(struct btd_adapter *adapter, int timeout) { GSList *l, *next; @@ -2061,11 +2039,6 @@ static void discovery_cleanup(struct btd_adapter *adapter, int timeout) adapter->discovery_idle_timeout = 0; } - if (adapter->temp_devices_timeout > 0) { - g_source_remove(adapter->temp_devices_timeout); - adapter->temp_devices_timeout = 0; - } - g_slist_free_full(adapter->discovery_found, invalidate_rssi_and_tx_power); adapter->discovery_found = NULL; @@ -2087,9 +2060,6 @@ static void discovery_cleanup(struct btd_adapter *adapter, int timeout) btd_adapter_remove_device(adapter, dev); } - - adapter->temp_devices_timeout = g_timeout_add_seconds(timeout, - remove_temp_devices, adapter); } static void discovery_free(void *user_data) @@ -3181,20 +3151,8 @@ static void discovery_destroy(void *user_data) adapter->discovery_type = 0x00; #endif - if (adapter->discovery_idle_timeout > 0) { - g_source_remove(adapter->discovery_idle_timeout); - adapter->discovery_idle_timeout = 0; - } - - if (adapter->temp_devices_timeout > 0) { - g_source_remove(adapter->temp_devices_timeout); - adapter->temp_devices_timeout = 0; - } - discovery_cleanup(adapter, 0); - adapter->temp_devices_timeout = g_timeout_add_seconds(TEMP_DEV_TIMEOUT, - remove_temp_devices, adapter); } static void discovery_disconnect(DBusConnection *conn, void *user_data) @@ -3269,11 +3227,6 @@ static void le_discovery_destroy(void *user_data) adapter->discovery_idle_timeout = 0; } - if (adapter->temp_devices_timeout > 0) { - g_source_remove(adapter->temp_devices_timeout); - adapter->temp_devices_timeout = 0; - } - discovery_cleanup(adapter, 0); } @@ -11422,11 +11375,6 @@ static void adapter_remove(struct btd_adapter *adapter) adapter->discovery_idle_timeout = 0; } - if (adapter->temp_devices_timeout > 0) { - g_source_remove(adapter->temp_devices_timeout); - adapter->temp_devices_timeout = 0; - } - discovery_cleanup(adapter, 0); g_slist_free(adapter->connect_list); -- 2.34.1