From 71cd97d34ed8c652074b61ed4093b475e2fb4fdd Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Fri, 6 May 2022 08:01:49 -0700 Subject: [PATCH] fix: missing waker.wake My analysis of the problem is that using the current `Reactor::ticker` value in `ticks` is not always correct. It is my understanding that when placing a ticker value into `Direction::ticks` there is a guarantee that the waker.wake call has completed and the associated task has been run. The problem is the increment of the ticker value is in `ReactorLock::react` is typically running on a different CPU thread than the `Source::poll_ready` (called by `poll_readable`, `poll_writeable`), which is saving the ticker value in ticks: state[dir].ticks = Some((Reactor::get().ticker(), state[dir].tick)); Because the increment and use of ticker value are on different threads the required guarantee can not be full filled and I'm proposing the following fix in this PR, which only uses the a current `state[dir].tick` and not the ticker value: state[dir].ticks = Some((state[dir].tick, 0) fix #78 --- src/reactor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reactor.rs b/src/reactor.rs index b6ae153..b48933a 100644 --- a/src/reactor.rs +++ b/src/reactor.rs @@ -431,7 +431,7 @@ impl Source { panic::catch_unwind(|| w.wake()).ok(); } state[dir].waker = Some(cx.waker().clone()); - state[dir].ticks = Some((Reactor::get().ticker(), state[dir].tick)); + state[dir].ticks = Some((state[dir].tick, 0)); // Update interest in this I/O handle. if was_empty {