Skip to content

Commit

Permalink
Cherry-pick 08c21e7
Browse files Browse the repository at this point in the history
    * Fix races.

    This mostly pulls in changes from rust-lang/futures-rs#881, but
    also updates Registration to be a bit more obvious as to what is going
    on.

    * Reduce spurious wakeups caused by Reactor

    This patch adds an ABA guard on token values before registering them
    with Mio. This allows catching token reuse and avoid the notification.

    This is needed for OS X as the notification is used to determine that a
    TCP connect has completed. A spurious notification can potentially cause
    write failures.
  • Loading branch information
kpp committed Mar 23, 2018
1 parent 8c00bd9 commit 816fe93
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tokio-threadpool/src/shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ impl Future for Shutdown {
type Error = ();

fn poll(&mut self) -> Poll<(), ()> {
use futures::task;
trace!("Shutdown::poll");

self.inner().shutdown_task.task1.register();
self.inner().shutdown_task.task1.register_task(task::current());

if 0 != self.inner().num_workers.load(Acquire) {
return Ok(Async::NotReady);
Expand Down
2 changes: 1 addition & 1 deletion tokio-threadpool/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl Task {
let actual = self.inner().state.compare_and_swap(
Idle.into(),
Scheduled.into(),
Relaxed).into();
AcqRel).into();

match actual {
Idle => return true,
Expand Down

0 comments on commit 816fe93

Please sign in to comment.