File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -42,8 +42,18 @@ fn file_with_options(
4242#[ cfg( not( target_os = "windows" ) ) ]
4343fn file_with_options (
4444 path : impl AsRef < Path > ,
45- options : std:: fs:: OpenOptions ,
45+ mut options : std:: fs:: OpenOptions ,
4646) -> io:: Result < std:: fs:: File > {
47+ use std:: os:: unix:: prelude:: OpenOptionsExt ;
48+
49+ // Don't set nonblocking with epoll.
50+ if cfg ! ( not( any(
51+ target_os = "linux" ,
52+ target_os = "android" ,
53+ target_os = "illumos"
54+ ) ) ) {
55+ options. custom_flags ( libc:: O_NONBLOCK ) ;
56+ }
4757 options. open ( path)
4858}
4959
@@ -252,11 +262,10 @@ impl File {
252262 let mut total_written = 0 ;
253263 let mut written;
254264 while total_written < buf_len {
255- ( written, buffer) = buf_try ! (
256- self . write_at( buffer. slice( total_written..) , pos + total_written)
257- . await
258- . into_inner( )
259- ) ;
265+ ( written, buffer) = buf_try ! ( self
266+ . write_at( buffer. slice( total_written..) , pos + total_written)
267+ . await
268+ . into_inner( ) ) ;
260269 total_written += written;
261270 }
262271 ( Ok ( total_written) , buffer)
Original file line number Diff line number Diff line change @@ -59,8 +59,12 @@ impl Socket {
5959 // non blocking socket when there is no connections in listen queue
6060 //
6161 // https://patchwork.kernel.org/project/linux-block/patch/[email protected] /#22949861 62- #[ cfg( all( unix, not( all( target_os = "linux" , feature = "io-uring" ) ) ) ) ]
63- socket. set_nonblocking ( true ) ?;
62+ if cfg ! ( all(
63+ unix,
64+ not( all( target_os = "linux" , feature = "io-uring" ) )
65+ ) ) {
66+ socket. set_nonblocking ( true ) ?;
67+ }
6468 Ok ( Self :: from_socket2 ( socket) )
6569 }
6670
You can’t perform that action at this time.
0 commit comments