Bluetooth: Mesh: Fix postponing storage deadline indefinitely
If the local node keeps getting bombarded with messages, it's possible that the storage timer gets rescheduled over and over again and never expires. Add the necessary code to only reschedule the timer if the new deadline is earlier than an existing one. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
c0a7e4d778
commit
e9ed634654
1 changed files with 7 additions and 1 deletions
|
@ -821,7 +821,7 @@ BT_SETTINGS_DEFINE(mesh, mesh_set, mesh_commit, NULL);
|
||||||
|
|
||||||
static void schedule_store(int flag)
|
static void schedule_store(int flag)
|
||||||
{
|
{
|
||||||
s32_t timeout;
|
s32_t timeout, remaining;
|
||||||
|
|
||||||
atomic_set_bit(bt_mesh.flags, flag);
|
atomic_set_bit(bt_mesh.flags, flag);
|
||||||
|
|
||||||
|
@ -836,6 +836,12 @@ static void schedule_store(int flag)
|
||||||
timeout = K_SECONDS(CONFIG_BT_MESH_STORE_TIMEOUT);
|
timeout = K_SECONDS(CONFIG_BT_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);
|
BT_DBG("Waiting %d seconds", timeout / MSEC_PER_SEC);
|
||||||
|
|
||||||
k_delayed_work_submit(&pending_store, timeout);
|
k_delayed_work_submit(&pending_store, timeout);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue