summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2020-12-07 11:24:15 -0800
committerGitHub <noreply@github.com>2020-12-07 11:24:15 -0800
commit62023dffe5396ee1a0380f12c7530bf4ff59fe4a (patch)
treec891a48ce299e6cfd01090a880d1baf16ebe0ad7
parent0707f4c19210d6dac620c663e94d34834714a7c9 (diff)
sync: forward port 0.2 mpsc test (#3225)
Forward ports the test included in #3215. The mpsc sempahore has been replaced in 0.3 and does not include the bug being fixed.
-rw-r--r--tokio/tests/sync_mpsc.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/tokio/tests/sync_mpsc.rs b/tokio/tests/sync_mpsc.rs
index adefcb12..ddbbf9ea 100644
--- a/tokio/tests/sync_mpsc.rs
+++ b/tokio/tests/sync_mpsc.rs
@@ -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());
+}