Skip to content

Commit

Permalink
Fix max limit in Client::new: Use PIPE_BUF
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 Jun 30, 2022
1 parent 210170b commit 466b694
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/unix.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use libc::c_int;
use libc::{c_int, PIPE_BUF};

use std::fs::File;
use std::io::{self, Read, Write};
use std::mem;
Expand All @@ -22,7 +23,7 @@ pub struct Acquired {

impl Client {
pub fn new(mut limit: usize) -> io::Result<Client> {
if limit > 4096 {
if limit > PIPE_BUF {
return Err(io::Error::new(io::ErrorKind::Other, "Can't have limit larger than 4096 since the pipe would block forever when writing to it"));
}

Expand Down

0 comments on commit 466b694

Please sign in to comment.