mirror of
https://github.com/wez/wezterm.git
synced 2024-09-21 03:39:16 +03:00
fix pollable_channel to be non-blocking on Windows
Upgrade filedescriptor to 0.7 to use the portable helper for setting non-blocking mode, and enable non-blocking mode on Windows.
This commit is contained in:
parent
101aedd6a5
commit
256b4e6da8
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -719,7 +719,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filedescriptor"
|
name = "filedescriptor"
|
||||||
version = "0.6.0"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
"anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1739,7 +1739,7 @@ version = "0.2.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
"anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"filedescriptor 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"filedescriptor 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -2509,7 +2509,7 @@ dependencies = [
|
|||||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cassowary 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cassowary 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"derive_builder 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"derive_builder 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"filedescriptor 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"filedescriptor 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -2836,7 +2836,7 @@ dependencies = [
|
|||||||
"euclid 0.20.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.20.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"filedescriptor 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"filedescriptor 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"font-kit 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"font-kit 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"font-loader 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"font-loader 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fontconfig 0.1.0",
|
"fontconfig 0.1.0",
|
||||||
@ -2944,7 +2944,7 @@ dependencies = [
|
|||||||
"core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-graphics 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-graphics 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.20.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.20.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"filedescriptor 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"filedescriptor 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glium 0.26.0-alpha6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glium 0.26.0-alpha6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -3187,7 +3187,7 @@ dependencies = [
|
|||||||
"checksum expat-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa"
|
"checksum expat-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa"
|
||||||
"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9"
|
"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9"
|
||||||
"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08"
|
"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08"
|
||||||
"checksum filedescriptor 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08f0c21550f7dab3f61284df9ad7fbd094c667daa33fac908e90e168cb0ff9b7"
|
"checksum filedescriptor 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2635e33a91cc1551a5e6b0e7386529add2874da81ed0db79134a2c2ad65b3efb"
|
||||||
"checksum filetime 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d"
|
"checksum filetime 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d"
|
||||||
"checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f"
|
"checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f"
|
||||||
"checksum float-ord 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e"
|
"checksum float-ord 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e"
|
||||||
|
@ -23,7 +23,7 @@ crossbeam-channel = "0.3"
|
|||||||
dirs = "1.0"
|
dirs = "1.0"
|
||||||
downcast-rs = "1.0"
|
downcast-rs = "1.0"
|
||||||
euclid = "0.20"
|
euclid = "0.20"
|
||||||
filedescriptor = "0.6"
|
filedescriptor = "0.7"
|
||||||
pretty_env_logger = "0.3"
|
pretty_env_logger = "0.3"
|
||||||
failure = "0.1"
|
failure = "0.1"
|
||||||
failure_derive = "0.1"
|
failure_derive = "0.1"
|
||||||
|
@ -10,7 +10,7 @@ documentation = "https://docs.rs/portable-pty"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
filedescriptor = "0.6"
|
filedescriptor = "0.7"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
shell-words = "0.1"
|
shell-words = "0.1"
|
||||||
|
@ -97,14 +97,10 @@ impl<T> AsPollFd for PollableReceiver<T> {
|
|||||||
/// windows 10 w/unix domain socket support.
|
/// windows 10 w/unix domain socket support.
|
||||||
pub fn pollable_channel<T>() -> anyhow::Result<(PollableSender<T>, PollableReceiver<T>)> {
|
pub fn pollable_channel<T>() -> anyhow::Result<(PollableSender<T>, PollableReceiver<T>)> {
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
let (write, read) = socketpair()?;
|
let (mut write, mut read) = socketpair()?;
|
||||||
|
|
||||||
#[cfg(unix)]
|
write.set_non_blocking(true)?;
|
||||||
unsafe {
|
read.set_non_blocking(true)?;
|
||||||
let on = 1;
|
|
||||||
libc::ioctl(write.as_raw_file_descriptor(), libc::FIONBIO, &on);
|
|
||||||
libc::ioctl(read.as_raw_file_descriptor(), libc::FIONBIO, &on);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
PollableSender {
|
PollableSender {
|
||||||
|
@ -16,7 +16,7 @@ bitflags = "1.0"
|
|||||||
cassowary = {version="0.3", optional=true}
|
cassowary = {version="0.3", optional=true}
|
||||||
derive_builder = "0.7"
|
derive_builder = "0.7"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
filedescriptor = "0.6"
|
filedescriptor = "0.7"
|
||||||
fnv = {version="1.0", optional=true}
|
fnv = {version="1.0", optional=true}
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
@ -60,13 +60,7 @@ impl TtyReadHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_blocking(&mut self, blocking: Blocking) -> Result<(), Error> {
|
fn set_blocking(&mut self, blocking: Blocking) -> Result<(), Error> {
|
||||||
let value: libc::c_int = match blocking {
|
self.fd.set_non_blocking(blocking == Blocking::DoNotWait)?;
|
||||||
Blocking::Wait => 0,
|
|
||||||
Blocking::DoNotWait => 1,
|
|
||||||
};
|
|
||||||
if unsafe { libc::ioctl(self.fd.as_raw_fd(), libc::FIONBIO, &value as *const _) } != 0 {
|
|
||||||
bail!("failed to ioctl(FIONBIO): {:?}", IoError::last_os_error());
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ winapi = { version = "0.3", features = [
|
|||||||
clipboard-win = "2.2"
|
clipboard-win = "2.2"
|
||||||
|
|
||||||
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
|
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
|
||||||
filedescriptor = "0.6"
|
filedescriptor = "0.7"
|
||||||
x11 = {version ="2.18", features = ["xlib_xcb"]}
|
x11 = {version ="2.18", features = ["xlib_xcb"]}
|
||||||
xcb = "0.8"
|
xcb = "0.8"
|
||||||
# See: https://github.com/meh/rust-xcb-util/issues/12
|
# See: https://github.com/meh/rust-xcb-util/issues/12
|
||||||
|
@ -813,10 +813,7 @@ impl WindowOps for WaylandWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn write_pipe_with_timeout(mut file: FileDescriptor, data: &[u8]) -> anyhow::Result<()> {
|
fn write_pipe_with_timeout(mut file: FileDescriptor, data: &[u8]) -> anyhow::Result<()> {
|
||||||
let on: libc::c_int = 1;
|
file.set_non_blocking(true)?;
|
||||||
unsafe {
|
|
||||||
libc::ioctl(file.as_raw_fd(), libc::FIONBIO, &on);
|
|
||||||
}
|
|
||||||
let mut pfd = libc::pollfd {
|
let mut pfd = libc::pollfd {
|
||||||
fd: file.as_raw_fd(),
|
fd: file.as_raw_fd(),
|
||||||
events: libc::POLLOUT,
|
events: libc::POLLOUT,
|
||||||
@ -847,10 +844,7 @@ fn write_pipe_with_timeout(mut file: FileDescriptor, data: &[u8]) -> anyhow::Res
|
|||||||
fn read_pipe_with_timeout(mut file: FileDescriptor) -> anyhow::Result<String> {
|
fn read_pipe_with_timeout(mut file: FileDescriptor) -> anyhow::Result<String> {
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::new();
|
||||||
|
|
||||||
let on: libc::c_int = 1;
|
file.set_non_blocking(true)?;
|
||||||
unsafe {
|
|
||||||
libc::ioctl(file.as_raw_fd(), libc::FIONBIO, &on);
|
|
||||||
}
|
|
||||||
let mut pfd = libc::pollfd {
|
let mut pfd = libc::pollfd {
|
||||||
fd: file.as_raw_fd(),
|
fd: file.as_raw_fd(),
|
||||||
events: libc::POLLIN,
|
events: libc::POLLIN,
|
||||||
|
@ -123,12 +123,9 @@ impl SpawnQueue {
|
|||||||
// We can't affort to use a blocking pipe for the wakeup
|
// We can't affort to use a blocking pipe for the wakeup
|
||||||
// because the write needs to hold a mutex and that
|
// because the write needs to hold a mutex and that
|
||||||
// can block reads as well as other writers.
|
// can block reads as well as other writers.
|
||||||
let pipe = Pipe::new().map_err(anyhow::Error::msg)?;
|
let mut pipe = Pipe::new()?;
|
||||||
let on = 1;
|
pipe.write.set_non_blocking(true)?;
|
||||||
unsafe {
|
pipe.read.set_non_blocking(true)?;
|
||||||
libc::ioctl(pipe.write.as_raw_fd(), libc::FIONBIO, &on);
|
|
||||||
libc::ioctl(pipe.read.as_raw_fd(), libc::FIONBIO, &on);
|
|
||||||
}
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
spawned_funcs: Mutex::new(VecDeque::new()),
|
spawned_funcs: Mutex::new(VecDeque::new()),
|
||||||
spawned_funcs_low_pri: Mutex::new(VecDeque::new()),
|
spawned_funcs_low_pri: Mutex::new(VecDeque::new()),
|
||||||
|
Loading…
Reference in New Issue
Block a user