mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 09:27:47 +00:00
[netdata] update StartContextReuseTimer() to start time if not running (#8859)
This commit contains two changes to `StartContextReuseTimer()`: - We now start the context reuse timer only if the timer is not already scheduled (`mContextLastUsed` will be non-zero when reuse timer is already scheduled). - The `mTimer` (which is used as a periodic timer) is only started if it is not already running.
This commit is contained in:
@@ -1003,6 +1003,11 @@ void Leader::FreeContextId(uint8_t aContextId)
|
||||
|
||||
void Leader::StartContextReuseTimer(uint8_t aContextId)
|
||||
{
|
||||
// Start the reuse timer for `aContextId` if it is not already
|
||||
// scheduled.
|
||||
|
||||
VerifyOrExit(mContextLastUsed[aContextId - kMinContextId].GetValue() == 0);
|
||||
|
||||
mContextLastUsed[aContextId - kMinContextId] = TimerMilli::GetNow();
|
||||
|
||||
if (mContextLastUsed[aContextId - kMinContextId].GetValue() == 0)
|
||||
@@ -1010,7 +1015,13 @@ void Leader::StartContextReuseTimer(uint8_t aContextId)
|
||||
mContextLastUsed[aContextId - kMinContextId].SetValue(1);
|
||||
}
|
||||
|
||||
mTimer.Start(kStateUpdatePeriod);
|
||||
if (!mTimer.IsRunning())
|
||||
{
|
||||
mTimer.Start(kStateUpdatePeriod);
|
||||
}
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void Leader::StopContextReuseTimer(uint8_t aContextId) { mContextLastUsed[aContextId - kMinContextId].SetValue(0); }
|
||||
|
||||
Reference in New Issue
Block a user