From 5ed22e53d87997b770be490074500b2af621e87f Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Mon, 20 Jun 2022 09:51:48 -0400 Subject: [PATCH] Update nix to 0.24.0 --- druid-shell/Cargo.toml | 2 +- druid-shell/src/backend/wayland/surfaces/buffers.rs | 2 +- druid-shell/src/backend/x11/application.rs | 6 +++--- druid-shell/src/backend/x11/clipboard.rs | 13 ++----------- druid-shell/src/backend/x11/window.rs | 4 ++-- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/druid-shell/Cargo.toml b/druid-shell/Cargo.toml index e8c066cb6f..560cb4cb43 100755 --- a/druid-shell/Cargo.toml +++ b/druid-shell/Cargo.toml @@ -108,7 +108,7 @@ gdk-sys = { version = "0.14.0", optional = true } gtk-rs = { version = "0.14.0", features = ["v3_22"], package = "gtk", optional = true } glib-sys = { version = "0.14.0", optional = true } gtk-sys = { version = "0.14.0", optional = true } -nix = { version = "0.18.0", optional = true } +nix = { version = "0.24.0", optional = true } x11rb = { version = "0.8.0", features = ["allow-unsafe-code", "present", "render", "randr", "xfixes", "xkb", "resource_manager", "cursor"], optional = true } wayland-client = { version = "0.29", optional = true } wayland-protocols = { version = "0.29", optional = true } diff --git a/druid-shell/src/backend/wayland/surfaces/buffers.rs b/druid-shell/src/backend/wayland/surfaces/buffers.rs index 9cf55039a8..a97e0c9410 100644 --- a/druid-shell/src/backend/wayland/surfaces/buffers.rs +++ b/druid-shell/src/backend/wayland/surfaces/buffers.rs @@ -369,7 +369,7 @@ impl Shm { self.size = new_size; return Ok(()); } - Err(e) if matches!(e.as_errno(), Some(Errno::EINTR)) => { + Err(Errno::EINTR) => { // continue (try again) } Err(e) => { diff --git a/druid-shell/src/backend/x11/application.rs b/druid-shell/src/backend/x11/application.rs index cd3f105b9a..f0f371e94c 100644 --- a/druid-shell/src/backend/x11/application.rs +++ b/druid-shell/src/backend/x11/application.rs @@ -846,10 +846,10 @@ fn drain_idle_pipe(idle_read: RawFd) -> Result<(), Error> { let mut read_buf = [0u8; 16]; loop { match nix::unistd::read(idle_read, &mut read_buf[..]) { - Err(nix::Error::Sys(nix::errno::Errno::EINTR)) => {} + Err(nix::errno::Errno::EINTR) => {} // According to write(2), this is the outcome of reading an empty, O_NONBLOCK // pipe. - Err(nix::Error::Sys(nix::errno::Errno::EAGAIN)) => { + Err(nix::errno::Errno::EAGAIN) => { break; } Err(e) => { @@ -944,7 +944,7 @@ fn poll_with_timeout( } } - Err(nix::Error::Sys(nix::errno::Errno::EINTR)) => { + Err(nix::errno::Errno::EINTR) => { now = Instant::now(); } Err(e) => return Err(e.into()), diff --git a/druid-shell/src/backend/x11/clipboard.rs b/druid-shell/src/backend/x11/clipboard.rs index ff21e1e076..d4a38c49ab 100644 --- a/druid-shell/src/backend/x11/clipboard.rs +++ b/druid-shell/src/backend/x11/clipboard.rs @@ -689,17 +689,8 @@ fn wait_for_event_with_deadline( // Wait for the socket to be readable via poll() and try again match poll(&mut poll_fds, poll_timeout) { Ok(_) => {} - Err(nix::Error::Sys(nix::errno::Errno::EINTR)) => {} - Err(e) => return Err(nix_error_to_io(e).into()), + Err(nix::errno::Errno::EINTR) => {} + Err(e) => return Err(std::io::Error::from(e).into()), } } } - -fn nix_error_to_io(e: nix::Error) -> std::io::Error { - use std::io::{Error, ErrorKind}; - match e { - nix::Error::Sys(errno) => errno.into(), - nix::Error::InvalidPath | nix::Error::InvalidUtf8 => Error::new(ErrorKind::InvalidInput, e), - nix::Error::UnsupportedOperation => std::io::Error::new(ErrorKind::Other, e), - } -} diff --git a/druid-shell/src/backend/x11/window.rs b/druid-shell/src/backend/x11/window.rs index db61b5d2c6..a57c87539c 100644 --- a/druid-shell/src/backend/x11/window.rs +++ b/druid-shell/src/backend/x11/window.rs @@ -1544,8 +1544,8 @@ impl IdleHandle { fn wake(&self) { loop { match nix::unistd::write(self.pipe, &[0]) { - Err(nix::Error::Sys(nix::errno::Errno::EINTR)) => {} - Err(nix::Error::Sys(nix::errno::Errno::EAGAIN)) => {} + Err(nix::errno::Errno::EINTR) => {} + Err(nix::errno::Errno::EAGAIN) => {} Err(e) => { error!("Failed to write to idle pipe: {}", e); break;