diff --git a/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp b/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp index 8140d0055f1b2e..a6b1bbde423dfb 100644 --- a/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp +++ b/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp @@ -61,6 +61,24 @@ System::Clock::Timeout NodeLookupHandle::NextEventTimeout(System::Clock::Timesta { return mRequest.GetMinLookupTime() - elapsed; } + + if (HasLookupResult()) + { + // We can get here if we got our result before our min lookup time had + // elapsed, but time has passed between then and this attempt to re-arm + // the timer, such that now we are past our min lookup time. For + // example, this can happen because the timer is a bit delayed in firing + // but is now being re-scheduled due to a cancellation of a lookup or + // start of a new lookup. Or it could happen because + // OnOperationalNodeResolved got called close to our min lookup time, + // and we crossed that line while going through mActiveLookups and + // before we got to calling ReArmTimer. + // + // In this case, we should just fire the timer ASAP, since our min + // lookup time has elapsed and we have results. + return System::Clock::Timeout::zero(); + } + if (elapsed < mRequest.GetMaxLookupTime()) { return mRequest.GetMaxLookupTime() - elapsed;