From 791ee87880866d58380c04418c94fdd583effa67 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 4 Jun 2024 11:43:09 -0700 Subject: [PATCH] [dataset-manager] enhance starting of Pending Dataset delay timer (#10334) This commit updates and fixes how the Pending Dataset delay timer is started. It is now started only after the timestamps are checked and the local Pending Dataset is updated and saved to non-volatile storage from the `LocalSave()` method. In particular, we no longer start the delay timer from the `Save()` method, which reads the `Dataset` from a received `Message`. This is because we may receive a Pending Dataset with a timestamp that is older than the currently saved local Pending Dataset. In this case, the local Dataset is correctly not updated but without this change, we could start the delay timer for the received stale Pending Dataset. --- src/core/meshcop/dataset_manager.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/core/meshcop/dataset_manager.cpp b/src/core/meshcop/dataset_manager.cpp index 8a717551d..a78472da6 100644 --- a/src/core/meshcop/dataset_manager.cpp +++ b/src/core/meshcop/dataset_manager.cpp @@ -295,12 +295,7 @@ Error DatasetManager::Save(const Timestamp &aTimestamp, const Message &aMessage, SuccessOrExit(error = dataset.Write(aTimestamp)); } - SuccessOrExit(error = Save(dataset)); - - if (IsPendingDataset()) - { - Get().StartDelayTimer(dataset); - } + error = Save(dataset); exit: return error; @@ -368,11 +363,6 @@ void DatasetManager::SaveLocal(const Dataset &aDataset) { LocalSave(aDataset); - if (IsPendingDataset()) - { - Get().StartDelayTimer(aDataset); - } - switch (Get().GetRole()) { case Mle::kRoleDisabled: @@ -431,6 +421,11 @@ void DatasetManager::LocalSave(const Dataset &aDataset) mLocalTimestampValid = (aDataset.ReadTimestamp(mType, mLocalTimestamp) == kErrorNone); mLocalUpdateTime = TimerMilli::GetNow(); + + if (IsPendingDataset()) + { + Get().StartDelayTimer(aDataset); + } } void DatasetManager::SignalDatasetChange(void) const