Rollup merge of #112464 - eval-exec:exec/fix-connect_timeout-overflow, r=ChrisDenton
Fix windows `Socket::connect_timeout` overflow This PR want to close #112405 - [x] add unit test
This commit is contained in:
commit
816b659157
@ -46,6 +46,17 @@ fn connect_error() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
|
||||
fn connect_timeout_error() {
|
||||
let socket_addr = next_test_ip4();
|
||||
let result = TcpStream::connect_timeout(&socket_addr, Duration::MAX);
|
||||
assert!(!matches!(result, Err(e) if e.kind() == ErrorKind::TimedOut));
|
||||
|
||||
let _listener = TcpListener::bind(&socket_addr).unwrap();
|
||||
assert!(TcpStream::connect_timeout(&socket_addr, Duration::MAX).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn listen_localhost() {
|
||||
let socket_addr = next_test_ip4();
|
||||
|
@ -159,7 +159,7 @@ impl Socket {
|
||||
}
|
||||
|
||||
let mut timeout = c::timeval {
|
||||
tv_sec: timeout.as_secs() as c_long,
|
||||
tv_sec: cmp::min(timeout.as_secs(), c_long::MAX as u64) as c_long,
|
||||
tv_usec: (timeout.subsec_nanos() / 1000) as c_long,
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user