diff --git a/src/fd_readable_set.rs b/src/fd_readable_set.rs index b3b224d64..00f1a2308 100644 --- a/src/fd_readable_set.rs +++ b/src/fd_readable_set.rs @@ -1,17 +1,15 @@ use libc::c_int; use std::os::unix::prelude::*; -pub use fd_readable_set_t as FdReadableSet; - /// Returns `true` if the fd is or becomes readable within the given timeout. /// This returns `false` if the waiting is interrupted by a signal. pub fn is_fd_readable(fd: i32, timeout_usec: u64) -> bool { - fd_readable_set_t::is_fd_readable(fd, timeout_usec) + FdReadableSet::is_fd_readable(fd, timeout_usec) } /// Returns whether an fd is readable. pub fn poll_fd_readable(fd: i32) -> bool { - fd_readable_set_t::poll_fd_readable(fd) + FdReadableSet::poll_fd_readable(fd) } /// A modest wrapper around select() or poll(). @@ -19,7 +17,7 @@ pub fn poll_fd_readable(fd: i32) -> bool { /// This only handles readability. /// Apple's `man poll`: "The poll() system call currently does not support devices." #[cfg(target_os = "macos")] -pub struct fd_readable_set_t { +pub struct FdReadableSet { // The underlying fdset and nfds value to pass to select(). fdset_: libc::fd_set, nfds_: c_int, @@ -31,10 +29,10 @@ pub struct fd_readable_set_t { const kUsecPerSec: u64 = 1000 * kUsecPerMsec; #[cfg(target_os = "macos")] -impl fd_readable_set_t { +impl FdReadableSet { /// Construct an empty set. - pub fn new() -> fd_readable_set_t { - fd_readable_set_t { + pub fn new() -> FdReadableSet { + FdReadableSet { fdset_: unsafe { std::mem::zeroed() }, nfds_: 0, } @@ -114,15 +112,15 @@ pub fn poll_fd_readable(fd: RawFd) -> bool { } #[cfg(not(target_os = "macos"))] -pub struct fd_readable_set_t { +pub struct FdReadableSet { pollfds_: Vec, } #[cfg(not(target_os = "macos"))] -impl fd_readable_set_t { +impl FdReadableSet { /// Construct an empty set. - pub fn new() -> fd_readable_set_t { - fd_readable_set_t { + pub fn new() -> FdReadableSet { + FdReadableSet { pollfds_: Vec::new(), } } @@ -177,7 +175,7 @@ fn usec_to_poll_msec(timeout_usec: u64) -> c_int { if (timeout_usec % kUsecPerMsec) > kUsecPerMsec / 2 { timeout_msec += 1; } - if timeout_usec == fd_readable_set_t::kNoTimeout || timeout_msec > c_int::MAX as u64 { + if timeout_usec == FdReadableSet::kNoTimeout || timeout_msec > c_int::MAX as u64 { // Negative values mean wait forever in poll-speak. return -1; } diff --git a/src/topic_monitor.rs b/src/topic_monitor.rs index bd39a8e75..bdebc1d8c 100644 --- a/src/topic_monitor.rs +++ b/src/topic_monitor.rs @@ -20,7 +20,7 @@ set. This is the real power of topics: you can wait for a sigchld signal OR a thread exit. */ -use crate::fd_readable_set::fd_readable_set_t; +use crate::fd_readable_set::FdReadableSet; use crate::fds::{self, make_fd_nonblocking, AutoClosePipes}; use crate::flog::{FloggableDebug, FLOG}; use crate::wchar::WString; @@ -240,8 +240,7 @@ pub fn wait(&self) { // call until data is available (that is, fish would use 100% cpu while waiting for // processes). This call prevents that. if cfg!(feature = "tsan") { - let _ = - fd_readable_set_t::is_fd_readable(fd, fd_readable_set_t::kNoTimeout); + let _ = FdReadableSet::is_fd_readable(fd, FdReadableSet::kNoTimeout); } let mut ignored: u8 = 0; match unistd::read(fd, std::slice::from_mut(&mut ignored)) {