chiark / gitweb /
cargo: upgrade "nix" and get rid of old error klunk
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 15 Jul 2021 17:52:30 +0000 (18:52 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 15 Jul 2021 17:52:30 +0000 (18:52 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Cargo.lock
Cargo.toml
apitest/apitest.rs
src/timedfd.rs

index 6f8ec54ea30115ef9b0ab80a6a0270849797bf6c..0c06ad98a558cf800df037d26adac5bf11aa3305 100644 (file)
@@ -2152,9 +2152,9 @@ dependencies = [
 
 [[package]]
 name = "nix"
-version = "0.21.0"
+version = "0.22.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c3728fec49d363a50a8828a190b379a446cc5cf085c06259bbbeb34447e4ec7"
+checksum = "cf1e25ee6b412c2a1e3fcb6a4499a5c1bfe7f43e014bdce9a6b6666e5aa2d187"
 dependencies = [
  "bitflags",
  "cc",
@@ -2422,7 +2422,7 @@ dependencies = [
  "libc",
  "log 0.4.14",
  "mio 0.7.13",
- "nix 0.21.0",
+ "nix 0.22.0",
  "num",
  "num-derive",
  "num-traits",
index 344af61399da347ddcde3792280df5a1a5359103..c47ae05b1ba2879628ea86f36900e85cf2312f8c 100644 (file)
@@ -54,7 +54,7 @@ lazy-init="0.5"
 lazy_static="1"
 libc="0.2"
 log="0.4"
-nix="0.21"
+nix="0.22"
 num="0.4"
 num-derive="0.3"
 num-traits="0.2"
index 39d3ea2ea0468f388262e7b8013d1b206914c303..ad060f1723442e43f5c5e6bdb0062ce0b6ef8e12 100644 (file)
@@ -328,10 +328,9 @@ pub mod cleanup_notify {
   use anyhow::Context;
   use fehler::{throw, throws};
   use libc::_exit;
-  use nix::errno::Errno::*;
   use nix::{unistd::*, fcntl::OFlag};
   use nix::sys::signal::*;
-  use nix::Error::Sys;
+  use nix::Error as NE;
   use void::Void;
   use std::io;
   use std::os::unix::io::RawFd;
@@ -353,7 +352,7 @@ pub mod cleanup_notify {
       match nix::unistd::read(fd, &mut buf) {
         Ok(0) => break,
         Ok(_) => throw!(io::Error::from_raw_os_error(libc::EINVAL)),
-        Err(Sys(EINTR)) => continue,
+        Err(NE::EINTR) => continue,
         _ => throw!(io::Error::last_os_error()),
       }
     }
@@ -398,7 +397,7 @@ pub mod cleanup_notify {
               for fd in 2.. {
                 if fd == notify_writing_end { continue }
                 let r = close(fd);
-                if fd > writing_end && matches!(r, Err(Sys(EBADF))) {
+                if fd > writing_end && matches!(r, Err(NE::EBADF)) {
                   break;
                 }                  
               }
index 641b1fbad41940cce2b035829213679771e67e4a..1c694f1655f1f20855acb271d093fa8106e3b56d 100644 (file)
@@ -11,11 +11,8 @@ pub trait Timed {
 pub trait TimedRead : Timed + Read  { }
 pub trait TimedWrite: Timed + Write { }
 
-use io::ErrorKind as EK;
-
 use nix::fcntl::{fcntl, OFlag, FcntlArg};
 use nix::Error as NE;
-use nix::errno::Errno;
 
 use mio::Token;
 
@@ -55,18 +52,6 @@ impl AsRawFd for Fd {
   fn as_raw_fd(&self) -> RawFd { self.0 }
 }
 
-#[ext(pub)]
-impl nix::Error {
-  fn as_ioe(self) -> io::Error {
-    match self {
-      NE::Sys(e) => return io::Error::from_raw_os_error(e as i32),
-      NE::UnsupportedOperation => EK::Unsupported,
-      NE::InvalidPath          => EK::InvalidData,
-      NE::InvalidUtf8          => EK::InvalidData,
-    }.into()
-  }
-}
-
 impl<RW> TimedFd<RW> where RW: TimedFdReadWrite {
   /// Takes ownership of the fd
   ///
@@ -82,7 +67,7 @@ impl<RW> TimedFd<RW> where RW: TimedFdReadWrite {
   #[throws(io::Error)]
   fn from_fd(fd: Fd) -> Self {
     fcntl(fd.as_raw_fd(), FcntlArg::F_SETFL(OFlag::O_NONBLOCK))
-      .map_err(|e| e.as_ioe())?;
+      .map_err(|e| io::Error::from(e))?;
 
     let poll = mio::Poll::new()?;
     poll.registry().register(
@@ -116,9 +101,9 @@ impl<RW> TimedFd<RW> where RW: TimedFdReadWrite {
         if event.token() == Token(0) {
           match f(self.fd.as_raw_fd()) {
             Ok(got) => { break 'again got },
-            Err(NE::Sys(Errno::EINTR)) => continue 'again,
-            Err(NE::Sys(Errno::EAGAIN)) => break,
-            Err(ne) => throw!(ne.as_ioe()),
+            Err(NE::EINTR) => continue 'again,
+            Err(NE::EAGAIN) => break,
+            Err(ne) => throw!(ne),
           }
         }
       }