From 943d4249dcc17cd8b4d2250c4fa19116097248fa Mon Sep 17 00:00:00 2001 From: "Joshua M. Clulow" Date: Tue, 8 Dec 2020 08:34:33 +0000 Subject: [PATCH] illumos epoll may not wake up unless pipe is empty At present, mio makes use of the emulated epoll(5) available on illumos systems. On some versions of illumos the interaction between pipes and EPOLLET is not quite right. Specifically, a wakeup may only be triggered when the buffer pipe transitions from empty to non-empty. To work around this, flush the buffer for every call to wake(). --- src/sys/unix/waker.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sys/unix/waker.rs b/src/sys/unix/waker.rs index 1305bd689..a7cf484e5 100644 --- a/src/sys/unix/waker.rs +++ b/src/sys/unix/waker.rs @@ -137,6 +137,12 @@ mod pipe { } pub fn wake(&self) -> io::Result<()> { + // 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. + #[cfg(target_os = "illumos")] + self.empty(); + match (&self.sender).write(&[1]) { Ok(_) => Ok(()), Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => {