@@ -544,30 +544,33 @@ fn close_readwrite_smoke() {
544
544
}
545
545
546
546
#[ test]
547
+ // FIXME: https://github.com/fortanix/rust-sgx/issues/110
547
548
#[ cfg_attr( target_env = "sgx" , ignore) ]
549
+ // On windows, shutdown will not wake up blocking I/O operations.
550
+ #[ cfg_attr( windows, ignore) ]
548
551
fn close_read_wakes_up ( ) {
549
552
each_ip ( & mut |addr| {
550
- let a = t ! ( TcpListener :: bind( & addr) ) ;
551
- let ( tx1, rx) = channel :: < ( ) > ( ) ;
553
+ let listener = t ! ( TcpListener :: bind( & addr) ) ;
552
554
let _t = thread:: spawn ( move || {
553
- let _s = t ! ( a . accept( ) ) ;
554
- let _ = rx . recv ( ) ;
555
+ let ( stream , _ ) = t ! ( listener . accept( ) ) ;
556
+ stream
555
557
} ) ;
556
558
557
- let s = t ! ( TcpStream :: connect( & addr) ) ;
558
- let s2 = t ! ( s . try_clone( ) ) ;
559
- let ( tx , rx ) = channel ( ) ;
559
+ let mut stream = t ! ( TcpStream :: connect( & addr) ) ;
560
+ let stream2 = t ! ( stream . try_clone( ) ) ;
561
+
560
562
let _t = thread:: spawn ( move || {
561
- let mut s2 = s2;
562
- assert_eq ! ( t!( s2. read( & mut [ 0 ] ) ) , 0 ) ;
563
- tx. send ( ( ) ) . unwrap ( ) ;
563
+ let stream2 = stream2;
564
+
565
+ // to make it more likely that `read` happens before `shutdown`
566
+ thread:: sleep ( Duration :: from_millis ( 1000 ) ) ;
567
+
568
+ // this should wake up the reader up
569
+ t ! ( stream2. shutdown( Shutdown :: Read ) ) ;
564
570
} ) ;
565
- // this should wake up the child thread
566
- t ! ( s. shutdown( Shutdown :: Read ) ) ;
567
571
568
- // this test will never finish if the child doesn't wake up
569
- rx. recv ( ) . unwrap ( ) ;
570
- drop ( tx1) ;
572
+ // this `read` should get interrupted by `shutdown`
573
+ assert_eq ! ( t!( stream. read( & mut [ 0 ] ) ) , 0 ) ;
571
574
} )
572
575
}
573
576
0 commit comments