File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,8 @@ impl Client {
4040 limit -= n;
4141 }
4242
43+ set_nonblocking ( client. write . as_raw_fd ( ) , false ) ?;
44+
4345 Ok ( client)
4446 }
4547
@@ -64,14 +66,20 @@ impl Client {
6466 return Err ( err) ;
6567 }
6668 }
67- _ => return Ok ( Client :: from_fds ( pipes[ 0 ] , pipes[ 1 ] ) ) ,
69+ _ => {
70+ set_nonblocking ( pipes[ 1 ] , true ) ?;
71+ return Ok ( Client :: from_fds ( pipes[ 0 ] , pipes[ 1 ] ) ) ;
72+ }
6873 }
6974 }
7075 }
7176
7277 cvt ( libc:: pipe ( pipes. as_mut_ptr ( ) ) ) ?;
7378 drop ( set_cloexec ( pipes[ 0 ] , true ) ) ;
7479 drop ( set_cloexec ( pipes[ 1 ] , true ) ) ;
80+
81+ set_nonblocking ( pipes[ 1 ] , true ) ?;
82+
7583 Ok ( Client :: from_fds ( pipes[ 0 ] , pipes[ 1 ] ) )
7684 }
7785
@@ -334,6 +342,16 @@ fn set_cloexec(fd: c_int, set: bool) -> io::Result<()> {
334342 }
335343}
336344
345+ fn set_nonblocking ( fd : c_int , set : bool ) -> io:: Result < ( ) > {
346+ let status_flag = if set { libc:: O_NONBLOCK } else { 0 } ;
347+
348+ unsafe {
349+ cvt ( libc:: fcntl ( fd, libc:: F_SETFL , status_flag) ) ?;
350+ }
351+
352+ Ok ( ( ) )
353+ }
354+
337355fn cvt ( t : c_int ) -> io:: Result < c_int > {
338356 if t == -1 {
339357 Err ( io:: Error :: last_os_error ( ) )
You can’t perform that action at this time.
0 commit comments