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

On kqueue platforms, make it so the EV_EOF flag corresponds to the "is_interrupt" flag. #221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
25 changes: 17 additions & 8 deletions src/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,22 @@ impl Poller {

let mode_flags = mode_to_flags(mode);

let read_flags = if ev.readable {
let mut read_flags = if ev.readable {
kqueue::EventFlags::ADD | mode_flags
} else {
kqueue::EventFlags::DELETE
};
let write_flags = if ev.writable {
let mut write_flags = if ev.writable {
kqueue::EventFlags::ADD | mode_flags
} else {
kqueue::EventFlags::DELETE
};

if ev.extra.eof {
read_flags |= kqueue::EventFlags::EOF;
write_flags |= kqueue::EventFlags::EOF;
}

// A list of changes for kqueue.
let changelist = [
kqueue::Event::new(
Expand Down Expand Up @@ -322,7 +327,9 @@ impl Events {
writable: matches!(ev.filter(), kqueue::EventFilter::Write(..))
|| (matches!(ev.filter(), kqueue::EventFilter::Read(..))
&& (ev.flags().intersects(kqueue::EventFlags::EOF))),
extra: EventExtra,
extra: EventExtra {
eof: ev.flags().intersects(kqueue::EventFlags::EOF),
},
})
}

Expand All @@ -339,19 +346,21 @@ impl Events {

/// Extra information associated with an event.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct EventExtra;
pub struct EventExtra {
eof: bool,
}

impl EventExtra {
/// Create a new, empty version of this struct.
#[inline]
pub const fn empty() -> EventExtra {
EventExtra
EventExtra { eof: false }
}

/// Set the interrupt flag.
#[inline]
pub fn set_hup(&mut self, _value: bool) {
// No-op.
pub fn set_hup(&mut self, value: bool) {
self.eof = value;
}

/// Set the priority flag.
Expand All @@ -363,7 +372,7 @@ impl EventExtra {
/// Is the interrupt flag set?
#[inline]
pub fn is_hup(&self) -> bool {
false
self.eof
}

/// Is the priority flag set?
Expand Down
Loading