Skip to content

Commit 87a9e09

Browse files
committed
wc: remove splice_exact
1 parent db25551 commit 87a9e09

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/uu/wc/src/count_fast.rs

Lines changed: 7 additions & 4 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

@@ -59,9 +59,12 @@ fn count_bytes_using_splice(fd: &impl AsFd) -> Result<usize, usize> {
5959
loop {
6060
match splice(fd, &pipe_wr, MAX_ROOTLESS_PIPE_SIZE) {
6161
Ok(0) => return Ok(byte_count),
62-
Ok(res) => {
63-
byte_count += res;
64-
splice_exact(&pipe_rd, &null_file, res).map_err(|_| byte_count)?;
62+
Ok(mut discard) => {
63+
byte_count += discard;
64+
while discard > 0 {
65+
// pipe to null is not blocked. So this loop is just once at most cases...
66+
discard -= splice(&pipe_rd, &null_file, discard).map_err(|_| byte_count)?;
67+
}
6568
}
6669
Err(_) => return Err(byte_count),
6770
}

0 commit comments

Comments
 (0)