Skip to content

Commit

Permalink
Merge pull request #44 from tokio-rs/master
Browse files Browse the repository at this point in the history
tests: update Nix to 0.22.0 (tokio-rs#3951)
  • Loading branch information
sthagen committed Jul 11, 2021
2 parents c0c6e52 + 127983e commit ffa8a99
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion tokio/Cargo.toml
Expand Up @@ -109,7 +109,7 @@ signal-hook-registry = { version = "1.1.1", optional = true }

[target.'cfg(unix)'.dev-dependencies]
libc = { version = "0.2.42" }
nix = { version = "0.19.0" }
nix = { version = "0.22.0" }

[target.'cfg(windows)'.dependencies.winapi]
version = "0.3.8"
Expand Down
17 changes: 2 additions & 15 deletions tokio/tests/io_async_fd.rs
Expand Up @@ -13,7 +13,6 @@ use std::{
task::{Context, Waker},
};

use nix::errno::Errno;
use nix::unistd::{close, read, write};

use futures::{poll, FutureExt};
Expand Down Expand Up @@ -56,10 +55,6 @@ impl TestWaker {
}
}

fn is_blocking(e: &nix::Error) -> bool {
Some(Errno::EAGAIN) == e.as_errno()
}

#[derive(Debug)]
struct FileDescriptor {
fd: RawFd,
Expand All @@ -73,11 +68,7 @@ impl AsRawFd for FileDescriptor {

impl Read for &FileDescriptor {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
match read(self.fd, buf) {
Ok(n) => Ok(n),
Err(e) if is_blocking(&e) => Err(ErrorKind::WouldBlock.into()),
Err(e) => Err(io::Error::new(ErrorKind::Other, e)),
}
read(self.fd, buf).map_err(io::Error::from)
}
}

Expand All @@ -89,11 +80,7 @@ impl Read for FileDescriptor {

impl Write for &FileDescriptor {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
match write(self.fd, buf) {
Ok(n) => Ok(n),
Err(e) if is_blocking(&e) => Err(ErrorKind::WouldBlock.into()),
Err(e) => Err(io::Error::new(ErrorKind::Other, e)),
}
write(self.fd, buf).map_err(io::Error::from)
}

fn flush(&mut self) -> io::Result<()> {
Expand Down

1 comment on commit ffa8a99

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'sync_mpsc'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: ffa8a99 Previous: 6b6fbdd Ratio
send_large 66977 ns/iter (± 9727) 24529 ns/iter (± 4177) 2.73

This comment was automatically generated by workflow using github-action-benchmark.

CC: @tokio-rs/maintainers

Please sign in to comment.