mirror of
https://github.com/espressif/openthread.git
synced 2026-08-26 04:09:52 +00:00
[network-data] reuse mLastAttempt for the function of mLastAttemptWait (#4485)
This enhancement is based on that `mLastAttempt` with value `0` is equivalent to `mLastAttemptWait` with value `false`
This commit is contained in:
@@ -50,7 +50,6 @@ namespace NetworkData {
|
||||
NetworkData::NetworkData(Instance &aInstance, Type aType)
|
||||
: InstanceLocator(aInstance)
|
||||
, mType(aType)
|
||||
, mLastAttemptWait(false)
|
||||
, mLastAttempt(0)
|
||||
{
|
||||
mLength = 0;
|
||||
@@ -978,7 +977,7 @@ otError NetworkData::SendServerDataNotification(uint16_t aRloc16)
|
||||
Coap::Message * message = NULL;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
VerifyOrExit(!mLastAttemptWait || (TimerMilli::GetNow() - mLastAttempt < kDataResubmitDelay),
|
||||
VerifyOrExit(mLastAttempt.GetValue() == 0 || ((TimerMilli::GetNow() - mLastAttempt) < kDataResubmitDelay),
|
||||
error = OT_ERROR_ALREADY);
|
||||
|
||||
VerifyOrExit((message = Get<Coap::Coap>().NewMessage()) != NULL, error = OT_ERROR_NO_BUFS);
|
||||
@@ -1010,8 +1009,14 @@ otError NetworkData::SendServerDataNotification(uint16_t aRloc16)
|
||||
|
||||
if (mType == kTypeLocal)
|
||||
{
|
||||
mLastAttempt = TimerMilli::GetNow();
|
||||
mLastAttemptWait = true;
|
||||
mLastAttempt = TimerMilli::GetNow();
|
||||
|
||||
// `0` is a special value to indicate no delay limitation on sending SRV_DATA.ntf.
|
||||
// Here avoids possible impact in rate limitation of SRV_DATA.ntf in case of wrap.
|
||||
if (mLastAttempt.GetValue() == 0)
|
||||
{
|
||||
mLastAttempt.SetValue(1);
|
||||
}
|
||||
}
|
||||
|
||||
otLogInfoNetData("Sent server data notification");
|
||||
@@ -1028,7 +1033,7 @@ exit:
|
||||
|
||||
void NetworkData::ClearResubmitDelayTimer(void)
|
||||
{
|
||||
mLastAttemptWait = false;
|
||||
mLastAttempt.SetValue(0);
|
||||
}
|
||||
|
||||
} // namespace NetworkData
|
||||
|
||||
@@ -537,7 +537,6 @@ private:
|
||||
};
|
||||
|
||||
const Type mType;
|
||||
bool mLastAttemptWait;
|
||||
TimeMilli mLastAttempt;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user