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 {
40
40
limit -= n;
41
41
}
42
42
43
+ set_nonblocking ( client. write . as_raw_fd ( ) , false ) ?;
44
+
43
45
Ok ( client)
44
46
}
45
47
@@ -64,14 +66,20 @@ impl Client {
64
66
return Err ( err) ;
65
67
}
66
68
}
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
+ }
68
73
}
69
74
}
70
75
}
71
76
72
77
cvt ( libc:: pipe ( pipes. as_mut_ptr ( ) ) ) ?;
73
78
drop ( set_cloexec ( pipes[ 0 ] , true ) ) ;
74
79
drop ( set_cloexec ( pipes[ 1 ] , true ) ) ;
80
+
81
+ set_nonblocking ( pipes[ 1 ] , true ) ?;
82
+
75
83
Ok ( Client :: from_fds ( pipes[ 0 ] , pipes[ 1 ] ) )
76
84
}
77
85
@@ -334,6 +342,16 @@ fn set_cloexec(fd: c_int, set: bool) -> io::Result<()> {
334
342
}
335
343
}
336
344
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
+
337
355
fn cvt ( t : c_int ) -> io:: Result < c_int > {
338
356
if t == -1 {
339
357
Err ( io:: Error :: last_os_error ( ) )
You can’t perform that action at this time.
0 commit comments