File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,17 +52,13 @@ fn count_bytes_using_splice(fd: &impl AsFd) -> Result<usize, usize> {
5252 }
5353 }
5454 let ( pipe_rd, pipe_wr) = pipe :: < false > ( MAX_ROOTLESS_PIPE_SIZE ) . map_err ( |_| byte_count) ?;
55- loop {
56- match splice ( fd, & pipe_wr, MAX_ROOTLESS_PIPE_SIZE ) . map_err ( |_| byte_count) ? {
57- 0 => return Ok ( byte_count) ,
58- res => {
59- byte_count += res;
60- // pipe to null is not blocked. So this returns res at most cases
61- // next splice does not hang if we discarded 1+ pages
62- splice ( & pipe_rd, & null_file, res) . map_err ( |_| byte_count) ?;
63- }
64- }
55+ while let s @ 1 .. = splice ( fd, & pipe_wr, MAX_ROOTLESS_PIPE_SIZE ) . map_err ( |_| byte_count) ? {
56+ byte_count += s;
57+ // pipe to null is not blocked. So this returns the same length at most cases
58+ // next splice does not hang if we discarded 1+ pages
59+ splice ( & pipe_rd, & null_file, s) . map_err ( |_| byte_count) ?;
6560 }
61+ Ok ( byte_count)
6662}
6763
6864/// In the special case where we only need to count the number of bytes. There
You can’t perform that action at this time.
0 commit comments