Skip to content

Use set_nonblocking in Async::new on Windows #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,9 @@ impl<T: AsFd> Async<T> {
/// # std::io::Result::Ok(()) });
/// ```
pub fn new(io: T) -> io::Result<Async<T>> {
// Put the file descriptor in non-blocking mode.
let fd = io.as_fd();

// Put the file descriptor in non-blocking mode.
set_nonblocking(fd)?;

// SAFETY: It is impossible to drop the I/O source while it is registered through
Expand Down Expand Up @@ -733,11 +734,7 @@ impl<T: AsSocket> Async<T> {
let borrowed = io.as_socket();

// Put the socket in non-blocking mode.
//
// Safety: We assume `as_raw_socket()` returns a valid fd. When we can
// depend on Rust >= 1.63, where `AsFd` is stabilized, and when
// `TimerFd` implements it, we can remove this unsafe and simplify this.
rustix::io::ioctl_fionbio(borrowed, true)?;
set_nonblocking(borrowed)?;

// Create the registration.
//
Expand Down