diff options
| author | Josh Stone <jistone@redhat.com> | 2018-11-30 15:33:40 -0800 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2018-11-30 15:33:40 -0800 |
| commit | f107514aef0b25b0d959941df1e45b18a478151b (patch) | |
| tree | 2d82a76865ada6adc5a8a0325c55f1d13c290ba4 /src/libstd/net/tcp.rs | |
| parent | d48ab693d1ce99f30c0cf9abdf45c209824fe825 (diff) | |
| download | rust-f107514aef0b25b0d959941df1e45b18a478151b.tar.gz rust-f107514aef0b25b0d959941df1e45b18a478151b.zip | |
Deal with EINTR in net timeout tests
We've seen sporadic QE failures in the timeout tests on this assertion:
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
So there's an error, but not either of the expected kinds. Adding a
format to show the kind revealed `ErrorKind::Interrupted` (`EINTR`).
For the cases that were using `read`, we can just use `read_exact` to
keep trying after interruption. For those using `recv_from`, we have to
manually loop until we get a non-interrupted result.
Diffstat (limited to 'src/libstd/net/tcp.rs')
| -rw-r--r-- | src/libstd/net/tcp.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index ad212a54757..be797803233 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -1548,8 +1548,9 @@ mod tests { let mut buf = [0; 10]; let start = Instant::now(); - let kind = stream.read(&mut buf).err().expect("expected error").kind(); - assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut); + let kind = stream.read_exact(&mut buf).err().expect("expected error").kind(); + assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut, + "unexpected_error: {:?}", kind); assert!(start.elapsed() > Duration::from_millis(400)); drop(listener); } @@ -1570,8 +1571,9 @@ mod tests { assert_eq!(b"hello world", &buf[..]); let start = Instant::now(); - let kind = stream.read(&mut buf).err().expect("expected error").kind(); - assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut); + let kind = stream.read_exact(&mut buf).err().expect("expected error").kind(); + assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut, + "unexpected_error: {:?}", kind); assert!(start.elapsed() > Duration::from_millis(400)); drop(listener); } |
