Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial support for Rustix 0.38.x #129

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .cargo/config.toml
Empty file.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tracing = { version = "0.1.37", default-features = false }

[target.'cfg(any(unix, target_os = "fuchsia", target_os = "vxworks"))'.dependencies]
libc = "0.2.77"
rustix = { version = "0.37.11", features = ["process", "time", "fs", "std"], default-features = false }
rustix = { version = "0.38.6", features = ["process", "time", "fs", "std", "event"], default-features = false }

[target.'cfg(windows)'.dependencies]
concurrent-queue = "2.2.0"
Expand Down
23 changes: 10 additions & 13 deletions src/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use std::io;
use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd};
use std::time::Duration;

use rustix::event::{epoll, eventfd, EventfdFlags};
use rustix::fd::OwnedFd;
use rustix::io::{epoll, eventfd, read, write, EventfdFlags};
use rustix::io::{read, write};
use rustix::time::{
timerfd_create, timerfd_settime, Itimerspec, TimerfdClockId, TimerfdFlags, TimerfdTimerFlags,
Timespec,
Expand All @@ -31,7 +32,7 @@ impl Poller {
// Create an epoll instance.
//
// Use `epoll_create1` with `EPOLL_CLOEXEC`.
let epoll_fd = epoll::epoll_create(epoll::CreateFlags::CLOEXEC)?;
let epoll_fd = epoll::create(epoll::CreateFlags::CLOEXEC)?;

// Set up eventfd and timerfd.
let event_fd = eventfd(0, EventfdFlags::CLOEXEC | EventfdFlags::NONBLOCK)?;
Expand Down Expand Up @@ -94,10 +95,10 @@ impl Poller {
);
let _enter = span.enter();

epoll::epoll_add(
epoll::add(
&self.epoll_fd,
unsafe { rustix::fd::BorrowedFd::borrow_raw(fd) },
ev.key as u64,
epoll::EventData::new_u64(ev.key as u64),
epoll_flags(&ev, mode),
)?;

Expand All @@ -114,10 +115,10 @@ impl Poller {
);
let _enter = span.enter();

epoll::epoll_mod(
epoll::modify(
&self.epoll_fd,
unsafe { rustix::fd::BorrowedFd::borrow_raw(fd) },
ev.key as u64,
epoll::EventData::new_u64(ev.key as u64),
epoll_flags(&ev, mode),
)?;

Expand All @@ -133,7 +134,7 @@ impl Poller {
);
let _enter = span.enter();

epoll::epoll_del(&self.epoll_fd, unsafe {
epoll::delete(&self.epoll_fd, unsafe {
rustix::fd::BorrowedFd::borrow_raw(fd)
})?;

Expand Down Expand Up @@ -195,7 +196,7 @@ impl Poller {
};

// Wait for I/O events.
epoll::epoll_wait(&self.epoll_fd, &mut events.list, timeout_ms)?;
epoll::wait(&self.epoll_fd, &mut events.list, timeout_ms)?;
tracing::trace!(
epoll_fd = ?self.epoll_fd.as_raw_fd(),
res = ?events.list.len(),
Expand Down Expand Up @@ -310,10 +311,6 @@ impl Events {

/// Iterates over I/O events.
pub fn iter(&self) -> impl Iterator<Item = Event> + '_ {
self.list.iter().map(|(flags, data)| Event {
key: data as usize,
readable: flags.intersects(read_flags()),
writable: flags.intersects(write_flags()),
})
self.list.iter()
}
}
5 changes: 3 additions & 2 deletions src/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ use std::io;
use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd};
use std::time::Duration;

use rustix::event::kqueue;
use rustix::fd::OwnedFd;
use rustix::io::{fcntl_setfd, kqueue, Errno, FdFlags};
use rustix::io::{fcntl_setfd, Errno, FdFlags};

use crate::{Event, PollMode};

Expand Down Expand Up @@ -268,7 +269,7 @@ pub(crate) fn mode_to_flags(mode: PollMode) -> kqueue::EventFlags {
))]
mod notify {
use super::Poller;
use rustix::io::kqueue;
use rustix::event::kqueue;
use std::io;
use std::os::unix::io::RawFd;

Expand Down
4 changes: 2 additions & 2 deletions src/os/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::io;
use std::process::Child;
use std::time::Duration;

use rustix::io::kqueue;
use rustix::event::kqueue;

use super::__private::PollerSealed;
use __private::FilterSealed;
Expand Down Expand Up @@ -238,7 +238,7 @@ unsafe impl FilterSealed for Timer {
impl Filter for Timer {}

mod __private {
use rustix::io::kqueue;
use rustix::event::kqueue;

#[doc(hidden)]
pub unsafe trait FilterSealed {
Expand Down
Loading