Skip to content

Commit bcc8fbd

Browse files
committed
wc: remove splice_exact
1 parent 4da1068 commit bcc8fbd

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/uu/wc/src/count_fast.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const FILE_ATTRIBUTE_NORMAL: u32 = 128;
2727
#[cfg(any(target_os = "linux", target_os = "android"))]
2828
use libc::S_IFIFO;
2929
#[cfg(any(target_os = "linux", target_os = "android"))]
30-
use uucore::pipes::{MAX_ROOTLESS_PIPE_SIZE, pipe, splice, splice_exact};
30+
use uucore::pipes::{MAX_ROOTLESS_PIPE_SIZE, pipe, splice};
3131

3232
const BUF_SIZE: usize = 64 * 1024;
3333

@@ -61,7 +61,11 @@ fn count_bytes_using_splice(fd: &impl AsFd) -> Result<usize, usize> {
6161
Ok(0) => return Ok(byte_count),
6262
Ok(res) => {
6363
byte_count += res;
64-
splice_exact(&pipe_rd, &null_file, res).map_err(|_| byte_count)?;
64+
// pipe to null is not blocked. So this returns res at most cases
65+
// next splice does not hang if we discarded 1+ pages
66+
if splice(&pipe_rd, &null_file, res).map_err(|_| byte_count)? == 0 {
67+
return Err(byte_count);
68+
}
6569
}
6670
Err(_) => return Err(byte_count),
6771
}

0 commit comments

Comments
 (0)