Skip to content

Commit 59ee2ea

Browse files
authored
Use set_nonblocking in Async::new on Windows (#157)
On Unix, we are already using it.
1 parent d5bc619 commit 59ee2ea

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,9 @@ impl<T: AsFd> Async<T> {
656656
/// # std::io::Result::Ok(()) });
657657
/// ```
658658
pub fn new(io: T) -> io::Result<Async<T>> {
659-
// Put the file descriptor in non-blocking mode.
660659
let fd = io.as_fd();
660+
661+
// Put the file descriptor in non-blocking mode.
661662
set_nonblocking(fd)?;
662663

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

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

742739
// Create the registration.
743740
//

0 commit comments

Comments
 (0)