sync: fix mpsc/sempahore when releasing permits (#904)

This patch fixes Semaphore by adding a missing code path to the release
routine that handles the case where the waiter's node is queued in the
sempahore but has not yet been assigned the permit.

This fix is used by mpsc to handle the case when the Sender has called
`poll_ready` and is dropped before the permit is acquired.

Fixes #900
This commit is contained in:
Carl Lerche
2019-02-19 16:26:05 -08:00
committed by GitHub
parent 2d5aa82341
commit e3115231dd
4 changed files with 114 additions and 17 deletions
+1 -3
View File
@@ -346,9 +346,7 @@ impl Semaphore for (::semaphore::Semaphore, usize) {
}
fn drop_permit(&self, permit: &mut Permit) {
if permit.is_acquired() {
permit.release(&self.0);
}
permit.release(&self.0);
}
fn add_permit(&self) {