@@ -544,30 +544,33 @@ fn close_readwrite_smoke() {
544544}
545545
546546#[ test]
547+ // FIXME: https://github.com/fortanix/rust-sgx/issues/110
547548#[ cfg_attr( target_env = "sgx" , ignore) ]
549+ // On windows, shutdown will not wake up blocking I/O operations.
550+ #[ cfg_attr( windows, ignore) ]
548551fn close_read_wakes_up ( ) {
549552 each_ip ( & mut |addr| {
550- let a = t ! ( TcpListener :: bind( & addr) ) ;
551- let ( tx1, rx) = channel :: < ( ) > ( ) ;
553+ let listener = t ! ( TcpListener :: bind( & addr) ) ;
552554 let _t = thread:: spawn ( move || {
553- let _s = t ! ( a . accept( ) ) ;
554- let _ = rx . recv ( ) ;
555+ let ( stream , _ ) = t ! ( listener . accept( ) ) ;
556+ stream
555557 } ) ;
556558
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+
560562 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 ) ) ;
564570 } ) ;
565- // this should wake up the child thread
566- t ! ( s. shutdown( Shutdown :: Read ) ) ;
567571
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 ) ;
571574 } )
572575}
573576
0 commit comments