From 6b705b3053d2c777e05cb60c758202ff9d4b2e7d Mon Sep 17 00:00:00 2001 From: Marshall Pierce <575695+marshallpierce@users.noreply.github.com> Date: Fri, 27 Jun 2025 01:39:55 -0600 Subject: [PATCH] net: allow `pipe::OpenOptions::read_write` on Android (#7426) --- tokio/src/net/unix/pipe.rs | 10 +++++----- tokio/tests/net_unix_pipe.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tokio/src/net/unix/pipe.rs b/tokio/src/net/unix/pipe.rs index 7c279134d..65bd51ad8 100644 --- a/tokio/src/net/unix/pipe.rs +++ b/tokio/src/net/unix/pipe.rs @@ -120,7 +120,7 @@ pub fn pipe() -> io::Result<(Sender, Receiver)> { /// ``` #[derive(Clone, Debug)] pub struct OpenOptions { - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "android"))] read_write: bool, unchecked: bool, } @@ -131,7 +131,7 @@ impl OpenOptions { /// All options are initially set to `false`. pub fn new() -> OpenOptions { OpenOptions { - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "android"))] read_write: false, unchecked: false, } @@ -168,8 +168,8 @@ impl OpenOptions { /// .read_write(true) /// .open_receiver("path/to/a/fifo"); /// ``` - #[cfg(target_os = "linux")] - #[cfg_attr(docsrs, doc(cfg(target_os = "linux")))] + #[cfg(any(target_os = "linux", target_os = "android"))] + #[cfg_attr(docsrs, doc(cfg(any(target_os = "linux", target_os = "android"))))] pub fn read_write(&mut self, value: bool) -> &mut Self { self.read_write = value; self @@ -264,7 +264,7 @@ impl OpenOptions { .write(pipe_end == PipeEnd::Sender) .custom_flags(libc::O_NONBLOCK); - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "android"))] if self.read_write { options.read(true).write(true); } diff --git a/tokio/tests/net_unix_pipe.rs b/tokio/tests/net_unix_pipe.rs index d36610a16..7169b5b61 100644 --- a/tokio/tests/net_unix_pipe.rs +++ b/tokio/tests/net_unix_pipe.rs @@ -68,7 +68,7 @@ async fn fifo_simple_send() -> io::Result<()> { } #[tokio::test] -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg_attr(miri, ignore)] // No `mkfifo` in miri. async fn fifo_simple_send_sender_first() -> io::Result<()> { const DATA: &[u8] = b"this is some data to write to the fifo"; @@ -134,7 +134,7 @@ async fn fifo_multiple_writes() -> io::Result<()> { /// Checks behavior of a resilient reader (Receiver in O_RDWR access mode) /// with writers sequentially opening and closing a FIFO. #[tokio::test] -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg_attr(miri, ignore)] // No `socket` in miri. async fn fifo_resilient_reader() -> io::Result<()> { const DATA: &[u8] = b"this is some data to write to the fifo";