Skip to content

Commit 0a5230a

Browse files
committed
Refactor: Put all set_nonblocking into new
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
1 parent 57d9647 commit 0a5230a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/unix.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ impl Client {
2929
// wrong!
3030
const BUFFER: [u8; 128] = [b'|'; 128];
3131

32+
set_nonblocking(client.write.as_raw_fd(), true)?;
33+
3234
while limit > 0 {
3335
let n = limit.min(BUFFER.len());
3436

@@ -63,7 +65,6 @@ impl Client {
6365
}
6466
}
6567
_ => {
66-
set_nonblocking(pipes[1], true)?;
6768
return Ok(Client::from_fds(pipes[0], pipes[1]));
6869
}
6970
}
@@ -73,9 +74,6 @@ impl Client {
7374
cvt(libc::pipe(pipes.as_mut_ptr()))?;
7475
drop(set_cloexec(pipes[0], true));
7576
drop(set_cloexec(pipes[1], true));
76-
77-
set_nonblocking(pipes[1], true)?;
78-
7977
Ok(Client::from_fds(pipes[0], pipes[1]))
8078
}
8179

0 commit comments

Comments
 (0)