Skip to content

Commit

Permalink
fix deadlock on joinwaker wait cell
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Jul 25, 2022
1 parent d5a231d commit a35527f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions maitake/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,10 @@ where
OrDrop::Drop => drop(STO::from_raw(this)),
OrDrop::Action(PollAction::Enqueue) => Self::schedule(ptr),
OrDrop::Action(PollAction::WakeJoinWaiter) => {
this.as_ref().join_waker.wake();
// set the `CLOSED` bit on the wait cell so that the join waker
// will always know that the task has completed, even if a join
// waker was not present when we ended this poll.
this.as_ref().join_waker.close();
}
OrDrop::Action(PollAction::None) => {}
}
Expand Down Expand Up @@ -440,11 +443,7 @@ where
Ok(_) => Poll::Pending,
// we were notified while trying to register --- we can now read the
// output
Err(WaitCellError::Notifying) => continue,
// the other waitcell errors should never be returned.
Err(WaitCellError::Closed) => {
unreachable!("join waker `WaitCell` is never closed, this should never happen")
}
Err(WaitCellError::Notifying) | Err(WaitCellError::Closed) => continue,
Err(WaitCellError::Parking) => {
unreachable!("multiple threads should not race on a join waker...what do")
}
Expand Down

0 comments on commit a35527f

Please sign in to comment.