Skip to content

Commit b5c6c7e

Browse files
committed
Loosen timeout restrictions
1 parent 494901a commit b5c6c7e

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

src/libstd/net/tcp.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -933,17 +933,15 @@ mod tests {
933933
let listener = t!(TcpListener::bind(&addr));
934934

935935
let mut stream = t!(TcpStream::connect(&("localhost", addr.port())));
936-
t!(stream.set_read_timeout(Some(Duration::from_millis(10))));
936+
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));
937937

938938
let mut buf = [0; 10];
939939
let wait = Duration::span(|| {
940940
let kind = stream.read(&mut buf).err().expect("expected error").kind();
941941
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
942942
});
943-
assert!(wait > Duration::from_millis(5));
944-
// windows will sometimes extend this by ~500ms, so we'll just take the
945-
// fact that we did time out as a win :(
946-
assert!(cfg!(windows) || wait < Duration::from_millis(15));
943+
assert!(wait > Duration::from_millis(400));
944+
assert!(wait < Duration::from_millis(1600));
947945
}
948946

949947
#[test]
@@ -952,7 +950,7 @@ mod tests {
952950
let listener = t!(TcpListener::bind(&addr));
953951

954952
let mut stream = t!(TcpStream::connect(&("localhost", addr.port())));
955-
t!(stream.set_read_timeout(Some(Duration::from_millis(10))));
953+
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));
956954

957955
let mut other_end = t!(listener.accept()).0;
958956
t!(other_end.write_all(b"hello world"));
@@ -965,9 +963,7 @@ mod tests {
965963
let kind = stream.read(&mut buf).err().expect("expected error").kind();
966964
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
967965
});
968-
assert!(wait > Duration::from_millis(5));
969-
// windows will sometimes extend this by ~500ms, so we'll just take the
970-
// fact that we did time out as a win :(
971-
assert!(cfg!(windows) || wait < Duration::from_millis(15));
966+
assert!(wait > Duration::from_millis(400));
967+
assert!(wait < Duration::from_millis(1600));
972968
}
973969
}

src/libstd/net/udp.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -389,25 +389,23 @@ mod tests {
389389
let addr = next_test_ip4();
390390

391391
let mut stream = t!(UdpSocket::bind(&addr));
392-
t!(stream.set_read_timeout(Some(Duration::from_millis(10))));
392+
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));
393393

394394
let mut buf = [0; 10];
395395
let wait = Duration::span(|| {
396396
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
397397
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
398398
});
399-
assert!(wait > Duration::from_millis(5));
400-
// windows will sometimes extend this by ~500ms, so we'll just take the
401-
// fact that we did time out as a win :(
402-
assert!(cfg!(windows) || wait < Duration::from_millis(15));
399+
assert!(wait > Duration::from_millis(400));
400+
assert!(wait < Duration::from_millis(1600));
403401
}
404402

405403
#[test]
406404
fn test_read_with_timeout() {
407405
let addr = next_test_ip4();
408406

409407
let mut stream = t!(UdpSocket::bind(&addr));
410-
t!(stream.set_read_timeout(Some(Duration::from_millis(10))));
408+
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));
411409

412410
t!(stream.send_to(b"hello world", &addr));
413411

@@ -419,9 +417,7 @@ mod tests {
419417
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
420418
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
421419
});
422-
assert!(wait > Duration::from_millis(5));
423-
// windows will sometimes extend this by ~500ms, so we'll just take the
424-
// fact that we did time out as a win :(
425-
assert!(cfg!(windows) || wait < Duration::from_millis(15));
420+
assert!(wait > Duration::from_millis(400));
421+
assert!(wait < Duration::from_millis(1600));
426422
}
427423
}

0 commit comments

Comments
 (0)