Skip to content

Commit 5056e69

Browse files
committed
network.rs: Avoid connect_timeout with Duration::MAX for Windows
1 parent 486f7c3 commit 5056e69

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/network.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,17 @@ fn wait_for_tcp_socket(host_and_port: &str, timeout: Duration) -> Result<(), std
5656
let error = io::Error::new(io::ErrorKind::TimedOut, "Time is up");
5757
return Err(error);
5858
}
59-
let connect_res = TcpStream::connect_timeout(&address, timeout_left);
59+
60+
// NOTE: This distinction is mainly for Windows where
61+
// TcpStream::connect_timeout([,,], Duration::MAX)
62+
// seems to never return even when the target is available.
63+
// Seems like a bug.
64+
let connect_res = if timeout == Duration::MAX {
65+
TcpStream::connect(&address)
66+
} else {
67+
TcpStream::connect_timeout(&address, timeout_left)
68+
};
69+
6070
match connect_res {
6171
Ok(connection) => {
6272
let _ = connection.shutdown(Shutdown::Both);

0 commit comments

Comments
 (0)