mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-07 00:00:08 +02:00
net: allow pipe::OpenOptions::read_write on Android (#7426)
This commit is contained in:
@@ -120,7 +120,7 @@ pub fn pipe() -> io::Result<(Sender, Receiver)> {
|
|||||||
/// ```
|
/// ```
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct OpenOptions {
|
pub struct OpenOptions {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
read_write: bool,
|
read_write: bool,
|
||||||
unchecked: bool,
|
unchecked: bool,
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ impl OpenOptions {
|
|||||||
/// All options are initially set to `false`.
|
/// All options are initially set to `false`.
|
||||||
pub fn new() -> OpenOptions {
|
pub fn new() -> OpenOptions {
|
||||||
OpenOptions {
|
OpenOptions {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
read_write: false,
|
read_write: false,
|
||||||
unchecked: false,
|
unchecked: false,
|
||||||
}
|
}
|
||||||
@@ -168,8 +168,8 @@ impl OpenOptions {
|
|||||||
/// .read_write(true)
|
/// .read_write(true)
|
||||||
/// .open_receiver("path/to/a/fifo");
|
/// .open_receiver("path/to/a/fifo");
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
|
#[cfg_attr(docsrs, doc(cfg(any(target_os = "linux", target_os = "android"))))]
|
||||||
pub fn read_write(&mut self, value: bool) -> &mut Self {
|
pub fn read_write(&mut self, value: bool) -> &mut Self {
|
||||||
self.read_write = value;
|
self.read_write = value;
|
||||||
self
|
self
|
||||||
@@ -264,7 +264,7 @@ impl OpenOptions {
|
|||||||
.write(pipe_end == PipeEnd::Sender)
|
.write(pipe_end == PipeEnd::Sender)
|
||||||
.custom_flags(libc::O_NONBLOCK);
|
.custom_flags(libc::O_NONBLOCK);
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
if self.read_write {
|
if self.read_write {
|
||||||
options.read(true).write(true);
|
options.read(true).write(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ async fn fifo_simple_send() -> io::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
|
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
|
||||||
async fn fifo_simple_send_sender_first() -> io::Result<()> {
|
async fn fifo_simple_send_sender_first() -> io::Result<()> {
|
||||||
const DATA: &[u8] = b"this is some data to write to the fifo";
|
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)
|
/// Checks behavior of a resilient reader (Receiver in O_RDWR access mode)
|
||||||
/// with writers sequentially opening and closing a FIFO.
|
/// with writers sequentially opening and closing a FIFO.
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
#[cfg_attr(miri, ignore)] // No `socket` in miri.
|
#[cfg_attr(miri, ignore)] // No `socket` in miri.
|
||||||
async fn fifo_resilient_reader() -> io::Result<()> {
|
async fn fifo_resilient_reader() -> io::Result<()> {
|
||||||
const DATA: &[u8] = b"this is some data to write to the fifo";
|
const DATA: &[u8] = b"this is some data to write to the fifo";
|
||||||
|
|||||||
Reference in New Issue
Block a user