diff options
| author | bors <bors@rust-lang.org> | 2018-12-03 07:10:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-12-03 07:10:15 +0000 |
| commit | 25c375413ab8e24b01bef1d80d61dff58ef7bc1c (patch) | |
| tree | d186d4d1d194d2e35b9fd1fdcfe48459f0075080 /src/libstd/sys | |
| parent | a563ceb3b9471acbb827e27686c5cacadc49a032 (diff) | |
| parent | f107514aef0b25b0d959941df1e45b18a478151b (diff) | |
| download | rust-25c375413ab8e24b01bef1d80d61dff58ef7bc1c.tar.gz rust-25c375413ab8e24b01bef1d80d61dff58ef7bc1c.zip | |
Auto merge of #56394 - cuviper:interrupted-timeout, r=sfackler
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/sys')
| -rw-r--r-- | src/libstd/sys/unix/ext/net.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 55f43ccd7db..737437c76b7 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -1654,8 +1654,9 @@ mod test { or_panic!(stream.set_read_timeout(Some(Duration::from_millis(1000)))); let mut buf = [0; 10]; - let kind = stream.read(&mut buf).err().expect("expected error").kind(); - assert!(kind == io::ErrorKind::WouldBlock || kind == io::ErrorKind::TimedOut); + let kind = stream.read_exact(&mut buf).err().expect("expected error").kind(); + assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut, + "unexpected_error: {:?}", kind); } #[test] @@ -1675,8 +1676,9 @@ mod test { or_panic!(stream.read(&mut buf)); assert_eq!(b"hello world", &buf[..]); - let kind = stream.read(&mut buf).err().expect("expected error").kind(); - assert!(kind == io::ErrorKind::WouldBlock || kind == io::ErrorKind::TimedOut); + let kind = stream.read_exact(&mut buf).err().expect("expected error").kind(); + assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut, + "unexpected_error: {:?}", kind); } // Ensure the `set_read_timeout` and `set_write_timeout` calls return errors |
