From: Wootak Jung Date: Thu, 11 Jan 2024 00:09:19 +0000 (+0900) Subject: adapter: Fix issue where adv stop request disables unintended instance X-Git-Tag: accepted/tizen/7.0/unified/20240115.170647^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e0dd434b99dc855b0461c8d5ee0e028c60d239f;p=platform%2Fupstream%2Fbluez.git adapter: Fix issue where adv stop request disables unintended instance Reproduction steps: 1. adv1, adv2 are in progress 2. LE connected and adv2 has stopped for a while and is scheduled(timer) to restart 3. adv1 stop request before restart timer is run 4. timer is removed and adv1 is stopped 5. adv2 is not restarted even though it should Change-Id: I5d2f7a2ae87d87d180e92f380505e8118fc973b0 Signed-off-by: Wootak Jung --- diff --git a/src/adapter.c b/src/adapter.c index df93118e..9630bea5 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -376,6 +376,7 @@ struct btd_adapter { bool advertising; /* Advertising active */ gchar *version; /* Bluetooth Version */ uint8_t adv_tx_power; + uint8_t adv_restart_instance; guint adv_restart_timeout; bool le_discovering; /* LE Discovery active */ GSList *le_discovery_list; /* list of LE discovery clients */ @@ -4665,14 +4666,9 @@ static DBusMessage *adapter_set_advertising(DBusConnection *conn, DBUS_TYPE_INVALID)) return btd_error_invalid_args(msg); - if (adapter->adv_restart_timeout) { - if (enable) { - return btd_error_in_progress(msg); - } else { - DBG("Advertising stop received. No need to restart advertising"); - g_source_remove(adapter->adv_restart_timeout); - adapter->adv_restart_timeout = 0; - } + if (adapter->adv_restart_timeout && adapter->adv_restart_instance == slot_id) { + DBG("restart advertising slot_id %d restart is in progress", slot_id); + return btd_error_in_progress(msg); } DBG("%s advertising slot_id %d", enable ? "Enable" : "Disable", slot_id); @@ -13588,6 +13584,7 @@ static void multi_adv_state_change_callback(uint16_t index, uint16_t length, data->adapter = adapter; data->slot_id = ev->adv_instance; + adapter->adv_restart_instance = ev->adv_instance; adapter->adv_restart_timeout = g_timeout_add(300, multi_adv_start_timeout_cb, data); }