Skip to content

Commit

Permalink
feat: Make it so is_interrupt is set on EV_EOF
Browse files Browse the repository at this point in the history
Closes #213

Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull committed Dec 4, 2024
1 parent 033e3a8 commit 481dda0
Showing 1 changed file with 17 additions and 8 deletions.
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

0 comments on commit 481dda0

Please sign in to comment.