adapter: Return Busy error when setting is pending
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 4 Mar 2021 22:20:31 +0000 (14:20 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:34 +0000 (19:08 +0530)
This returns an error if application attempts to change a property that
is pending.

Fixes: https://github.com/bluez/bluez/issues/99
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/adapter.c

index 08c6ed4..8ffefff 100644 (file)
@@ -7015,12 +7015,18 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting,
 
        dbus_message_iter_get_basic(value, &enable);
 
+       if (adapter->pending_settings & setting) {
+               g_dbus_pending_property_error(id, ERROR_INTERFACE ".Busy",
+                                               NULL);
+               return;
+       }
+
        if (adapter->current_settings & setting)
                current_enable = TRUE;
        else
                current_enable = FALSE;
 
-       if (enable == current_enable || adapter->pending_settings & setting) {
+       if (enable == current_enable) {
                g_dbus_pending_property_success(id);
                return;
        }