File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ const FILE_ATTRIBUTE_NORMAL: u32 = 128;
2727#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
2828use 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
3232const 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 }
You can’t perform that action at this time.
0 commit comments