File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,17 @@ fn connect_error() {
4646 }
4747}
4848
49+ #[ test]
50+ #[ cfg_attr( target_env = "sgx" , ignore) ] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
51+ fn connect_timeout_error ( ) {
52+ let socket_addr = next_test_ip4 ( ) ;
53+ let result = TcpStream :: connect_timeout ( & socket_addr, Duration :: MAX ) ;
54+ assert ! ( !matches!( result, Err ( e) if e. kind( ) == ErrorKind :: TimedOut ) ) ;
55+
56+ let _listener = TcpListener :: bind ( & socket_addr) . unwrap ( ) ;
57+ assert ! ( TcpStream :: connect_timeout( & socket_addr, Duration :: MAX ) . is_ok( ) ) ;
58+ }
59+
4960#[ test]
5061fn listen_localhost ( ) {
5162 let socket_addr = next_test_ip4 ( ) ;
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ impl Socket {
159159 }
160160
161161 let mut timeout = c:: timeval {
162- tv_sec : timeout. as_secs ( ) as c_long ,
162+ tv_sec : cmp :: min ( timeout. as_secs ( ) , c_long :: MAX as u64 ) as c_long ,
163163 tv_usec : ( timeout. subsec_nanos ( ) / 1000 ) as c_long ,
164164 } ;
165165
You can’t perform that action at this time.
0 commit comments