]> granicus.if.org Git - esp-idf/commitdiff
ble_mesh: fix postponing storage deadline indefinitely
authorlly <lly@espressif.com>
Mon, 2 Sep 2019 06:17:47 +0000 (14:17 +0800)
committerlly <lly@espressif.com>
Mon, 9 Sep 2019 09:15:16 +0000 (17:15 +0800)
components/bt/esp_ble_mesh/mesh_core/settings.c

index 0a6a8b9c25847f4e41f7f79cb0cf1cade544d951..491782f400e1131867c4d0d9d3452268d15da7ff 100644 (file)
@@ -846,7 +846,7 @@ int settings_core_commit(void)
 
 static void schedule_store(int flag)
 {
-    s32_t timeout;
+    s32_t timeout, remaining;
 
     bt_mesh_atomic_set_bit(bt_mesh.flags, flag);
 
@@ -861,6 +861,12 @@ static void schedule_store(int flag)
         timeout = K_SECONDS(CONFIG_BLE_MESH_STORE_TIMEOUT);
     }
 
+    remaining = k_delayed_work_remaining_get(&pending_store);
+    if (remaining && remaining < timeout) {
+        BT_DBG("Not rescheduling due to existing earlier deadline");
+        return;
+    }
+
     BT_DBG("Waiting %d seconds", timeout / MSEC_PER_SEC);
 
     if (timeout) {