Skip to content

Commit

Permalink
sync: forward port 0.2 mpsc test
Browse files Browse the repository at this point in the history
Forward ports the test included in #3215. The mpsc sempahore has been
replaced in 0.3 and does not include the bug being fixed.
  • Loading branch information
carllerche committed Dec 7, 2020
1 parent 0707f4c commit 2ad1cd5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tokio/tests/sync_mpsc.rs
Expand Up @@ -483,3 +483,22 @@ async fn ready_close_cancel_bounded() {
let val = assert_ready!(recv.poll());
assert!(val.is_none());
}

#[tokio::test]
async fn permit_available_not_acquired_close() {
let (tx1, mut rx) = mpsc::channel::<()>(1);
let tx2 = tx1.clone();

let permit1 = assert_ok!(tx1.reserve().await);

let mut permit2 = task::spawn(tx2.reserve());
assert_pending!(permit2.poll());

rx.close();

drop(permit1);
assert!(permit2.is_woken());

drop(permit2);
assert!(rx.recv().await.is_none());
}

0 comments on commit 2ad1cd5

Please sign in to comment.