File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -566,7 +566,7 @@ impl<T> Sender<T> {
566566 tail : Mutex :: new ( Tail {
567567 pos : 0 ,
568568 rx_cnt : receiver_count,
569- closed : false ,
569+ closed : receiver_count == 0 ,
570570 waiters : LinkedList :: new ( ) ,
571571 } ) ,
572572 num_tx : AtomicUsize :: new ( 1 ) ,
Original file line number Diff line number Diff line change @@ -706,3 +706,17 @@ fn broadcast_sender_closed_with_extra_subscribe() {
706706 assert ! ( task3. is_woken( ) ) ;
707707 assert_ready ! ( task3. poll( ) ) ;
708708}
709+
710+ #[ tokio:: test]
711+ async fn broadcast_sender_new_must_be_closed ( ) {
712+ let capacity = 1 ;
713+ let tx: broadcast:: Sender < ( ) > = broadcast:: Sender :: new ( capacity) ;
714+
715+ let mut task = task:: spawn ( tx. closed ( ) ) ;
716+ assert_ready ! ( task. poll( ) ) ;
717+
718+ let _rx = tx. subscribe ( ) ;
719+
720+ let mut task2 = task:: spawn ( tx. closed ( ) ) ;
721+ assert_pending ! ( task2. poll( ) ) ;
722+ }
You can’t perform that action at this time.
0 commit comments