mirror of https://github.com/smol-rs/polling
Added CI check and inlined hack into pop_notification
This commit is contained in:
parent
ac07039ddb
commit
d1490e549b
|
@ -126,6 +126,9 @@ jobs:
|
|||
- name: Check haiku
|
||||
if: startsWith(matrix.rust, 'nightly') && matrix.os == 'ubuntu-latest'
|
||||
run: cargo check -Z build-std --target x86_64-unknown-haiku
|
||||
- name: Check vita
|
||||
if: startsWith(matrix.rust, 'nightly') && matrix.os == 'ubuntu-latest'
|
||||
run: cargo check -Z build-std --target armv7-sony-vita-newlibeabihf
|
||||
|
||||
wine:
|
||||
runs-on: ubuntu-22.04
|
||||
|
|
41
src/poll.rs
41
src/poll.rs
|
@ -222,28 +222,7 @@ impl Poller {
|
|||
if self.notified.swap(false, Ordering::SeqCst) {
|
||||
// `notify` will have sent a notification in case we were polling. We weren't,
|
||||
// so remove it.
|
||||
|
||||
// Pipes on Vita do not guarantee that after `write` call succeeds, the
|
||||
// data becomes immediately available for reading on the other side of the pipe.
|
||||
// To ensure that the notification is not lost, the read side of the pipe is temporarily
|
||||
// switched to blocking for a single `read` call.
|
||||
#[cfg(target_os = "vita")]
|
||||
rustix::fs::fcntl_setfl(
|
||||
&self.notify.read_pipe,
|
||||
rustix::fs::fcntl_getfl(&self.notify.read_pipe)?
|
||||
& !rustix::fs::OFlags::NONBLOCK,
|
||||
)?;
|
||||
|
||||
let notification = self.notify.pop_notification();
|
||||
|
||||
#[cfg(target_os = "vita")]
|
||||
rustix::fs::fcntl_setfl(
|
||||
&self.notify.read_pipe,
|
||||
rustix::fs::fcntl_getfl(&self.notify.read_pipe)?
|
||||
| rustix::fs::OFlags::NONBLOCK,
|
||||
)?;
|
||||
|
||||
return notification;
|
||||
return self.notify.pop_notification();
|
||||
} else if self.waiting_operations.load(Ordering::SeqCst) == 0 {
|
||||
break;
|
||||
}
|
||||
|
@ -667,7 +646,7 @@ mod notify {
|
|||
pub(super) struct Notify {
|
||||
/// The file descriptor of the read half of the notify pipe. This is also stored as the first
|
||||
/// file descriptor in `fds.poll_fds`.
|
||||
pub(super) read_pipe: OwnedFd,
|
||||
read_pipe: OwnedFd,
|
||||
/// The file descriptor of the write half of the notify pipe.
|
||||
///
|
||||
/// Data is written to this to wake up the current instance of `Poller::wait`, which can occur when the
|
||||
|
@ -720,8 +699,24 @@ mod notify {
|
|||
|
||||
/// Pops a notification (if any) from the pipe.
|
||||
pub(super) fn pop_notification(&self) -> Result<(), io::Error> {
|
||||
// Pipes on Vita do not guarantee that after `write` call succeeds, the
|
||||
// data becomes immediately available for reading on the other side of the pipe.
|
||||
// To ensure that the notification is not lost, the read side of the pipe is temporarily
|
||||
// switched to blocking for a single `read` call.
|
||||
#[cfg(target_os = "vita")]
|
||||
rustix::fs::fcntl_setfl(
|
||||
&self.read_pipe,
|
||||
rustix::fs::fcntl_getfl(&self.read_pipe)? & !rustix::fs::OFlags::NONBLOCK,
|
||||
)?;
|
||||
|
||||
read(&self.read_pipe, &mut [0; 1])?;
|
||||
|
||||
#[cfg(target_os = "vita")]
|
||||
rustix::fs::fcntl_setfl(
|
||||
&self.read_pipe,
|
||||
rustix::fs::fcntl_getfl(&self.read_pipe)? | rustix::fs::OFlags::NONBLOCK,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue