Skip to content

timeout: prevent lost wakeup in TimerStub::poll - #983

Open
cuishuang wants to merge 1 commit into
cloudflare:mainfrom
cuishuang:main
Open

timeout: prevent lost wakeup in TimerStub::poll#983
cuishuang wants to merge 1 commit into
cloudflare:mainfrom
cuishuang:main

Conversation

@cuishuang

Copy link
Copy Markdown

Summary

TimerStub::poll() could miss a timer notification if Timer::fire() ran after the initial fired flag check but before the waiter was registered.

Notify::notify_waiters() does not retain a permit for future waiters, so the poll could remain pending indefinitely.

This change:

  • registers and enables the Notified waiter before rechecking the fired flag;
  • returns immediately when the timer fires during that registration window;
  • adds a deterministic regression test covering the lost-wakeup race.

Tested by the following cmd:

  • cargo test -p pingora-timeout
  • cargo clippy -p pingora-timeout --all-targets -- -D warnings

Signed-off-by: cuishuang <imcusg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant