Skip to content

Commit

Permalink
Copy illumos waker pipe work around to eventfd
Browse files Browse the repository at this point in the history
It seems the same behaviour we seen for pipe waker implementation is
also true for eventfd. Work around this by resetting the waker before
writing to it.
  • Loading branch information
Thomasdezeeuw committed Aug 10, 2024
1 parent 4a5114e commit 619c909
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sys/unix/waker/eventfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ impl Waker {

#[allow(clippy::unused_io_amount)] // Don't care about partial writes.
pub(crate) fn wake(&self) -> io::Result<()> {
// The epoll emulation on some illumos systems currently requires
// the eventfd to be read before an edge-triggered read event is
// generated.
// See https://www.illumos.org/issues/16700.
#[cfg(target_os = "illumos")]
self.reset();

let buf: [u8; 8] = 1u64.to_ne_bytes();
match (&self.fd).write(&buf) {
Ok(_) => Ok(()),
Expand Down
1 change: 1 addition & 0 deletions src/sys/unix/waker/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl Waker {
// The epoll emulation on some illumos systems currently requires
// the pipe buffer to be completely empty for an edge-triggered
// wakeup on the pipe read side.
// See https://www.illumos.org/issues/16700.
#[cfg(target_os = "illumos")]
self.empty();

Expand Down

0 comments on commit 619c909

Please sign in to comment.