Skip to content

Commit

Permalink
add O_NONBLOCK for udp/tcp
Browse files Browse the repository at this point in the history
Signed-off-by: Akhil T Thomas <akhilthomasmec@gmail.com>
  • Loading branch information
AkhilTThomas committed Apr 1, 2024
1 parent 519d962 commit 81a6eee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/sys/unix/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream,
target_os = "espidf",
target_os = "vita",
target_os = "hermit",
target_os = "nto",
))]
syscall!(fcntl(s.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK))?;

Expand Down
1 change: 1 addition & 0 deletions src/sys/unix/uds/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So
all(target_arch = "x86", target_os = "android"),
target_os = "espidf",
target_os = "vita",
target_os = "nto",
))]
syscall!(fcntl(socket, libc::F_SETFL, libc::O_NONBLOCK))?;

Expand Down
6 changes: 3 additions & 3 deletions tests/unix_pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn smoke() {
}

#[test]
#[cfg_attr(target_os = "nto", ignore = "Read close events are detected by NTO")]
#[cfg_attr(target_os = "nto", ignore = "Writer fd close events do not trigger POLLHUP on nto target")]
fn event_when_sender_is_dropped() {
let mut poll = Poll::new().unwrap();
let mut events = Events::with_capacity(8);
Expand Down Expand Up @@ -92,7 +92,7 @@ fn event_when_sender_is_dropped() {
}

#[test]
#[cfg_attr(target_os = "nto", ignore = "Read close events are detected by NTO")]
#[cfg_attr(target_os = "nto", ignore = "Read fd close events do not trigger POLLHUP on nto target")]
fn event_when_receiver_is_dropped() {
let mut poll = Poll::new().unwrap();
let mut events = Events::with_capacity(8);
Expand Down Expand Up @@ -126,7 +126,7 @@ fn event_when_receiver_is_dropped() {
}

#[test]
#[cfg_attr(target_os = "nto", ignore = "Read close events are detected by NTO")]
#[cfg_attr(target_os = "nto", ignore = "Read/Write close eventsdo not trigger POLLHUP on nto target")]
fn from_child_process_io() {
// `cat` simply echo everything that we write via standard in.
let mut child = Command::new("cat")
Expand Down

0 comments on commit 81a6eee

Please sign in to comment.