Skip to content

Commit

Permalink
Make sure that we don't miss lookup result notifications.
Browse files Browse the repository at this point in the history
If we cross out min lookup time boundary between when we get a result
and when the next ReArmTimer call happens, we want to make sure we
don't end up waiting until our max lookup boundary.

Fixes #25049
  • Loading branch information
bzbarsky-apple committed Feb 16, 2023
1 parent 80ee243 commit 4c7578a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib/address_resolve/AddressResolve_DefaultImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4c7578a

Please sign in to comment.