Skip to content

Commit

Permalink
Refactor: Put all set_nonblocking into new
Browse files Browse the repository at this point in the history
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu committed Jul 2, 2022
1 parent 57d9647 commit 0a5230a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ impl Client {
// wrong!
const BUFFER: [u8; 128] = [b'|'; 128];

set_nonblocking(client.write.as_raw_fd(), true)?;

while limit > 0 {
let n = limit.min(BUFFER.len());

Expand Down Expand Up @@ -63,7 +65,6 @@ impl Client {
}
}
_ => {
set_nonblocking(pipes[1], true)?;
return Ok(Client::from_fds(pipes[0], pipes[1]));
}
}
Expand All @@ -73,9 +74,6 @@ impl Client {
cvt(libc::pipe(pipes.as_mut_ptr()))?;
drop(set_cloexec(pipes[0], true));
drop(set_cloexec(pipes[1], true));

set_nonblocking(pipes[1], true)?;

Ok(Client::from_fds(pipes[0], pipes[1]))
}

Expand Down

0 comments on commit 0a5230a

Please sign in to comment.