Repository navigation
Conversation
drcaramelsyrup
left a comment
There was a problem hiding this comment.
Thanks for the fix here. I think it looks good pending one minor unnecessary bit.
|
@drcaramelsyrup Thanks for pointing that out! You're right—creating the Notified future is sufficient for notify_waiters(), so I've removed both lines and squashed the change into the original commit. |
|
@cuishuang Thanks again, we saw a minor detail in internal review. We can apply it as another commit on top if desired or let you revise. |
Signed-off-by: cuishuang <imcusg@gmail.com>
@drcaramelsyrup Thanks for catching both of these! I updated poll() to return the inner future directly and kept only the fired flag check after creating Notified. I confirmed the future shrank from 128 to 104 bytes locally. All 18 tests and Clippy pass, and I’ve pushed the revision as a single commit. |
Summary
TimerStub::poll()could miss a timer notification ifTimer::fire()ran between the fired flag check and creation of theNotifiedfuture.notify_waiters()does not retain a permit for futures created after the notification, so the timer could remain pending indefinitely.Create the
Notifiedfuture before checking the fired flag once. A fire before creation is observed via the flag. A fire after creation reaches the future even before its first poll. Return the inner future directly sofast_timeoutboxes a smaller future (104 bytes versus 128 bytes for the previous revision on the local toolchain).The regression test fires the timer before creating the
Notifiedfuture and verifies the wait completes.Validation
cargo test -p pingora-timeout(18 passed)cargo clippy -p pingora-timeout --all-targets -- -D warningscargo fmt -p pingora-timeout -- --check