@@ -39,21 +39,14 @@ where
3939 R : Read + AsFd + AsRawFd ,
4040 S : Write + AsFd + AsRawFd ,
4141{
42- // If we're on Linux or Android, try to use the splice() system call
43- // for faster writing. If it works, we're done.
44- // todo: bypass broker pipe this if input or output is pipe. We use this mostly for stream.
45- if !crate :: pipes:: splice_unbounded_broker ( src, dest) ? {
46- return Ok ( ( ) ) ;
42+ // try to use the splice() system call
43+ // for faster writing. If it works, we're done
44+ if crate :: pipes:: splice_unbounded_auto ( & src, dest) ? {
45+ std:: io:: copy ( src, dest) ?;
46+ // todo: Do not mix writing by raw syscall and std's buffered write,
47+ // or order of output would be wrong when this was called multiple times
48+ // and splice_unbounded_auto sent content partially. flush works as an workaround.
49+ dest. flush ( ) ?;
4750 }
48-
49- // If the splice() call failed, fall back on slower writing.
50- std:: io:: copy ( src, dest) ?;
51-
52- // If the splice() call failed and there has been some data written to
53- // stdout via while loop above AND there will be second splice() call
54- // that will succeed, data pushed through splice will be output before
55- // the data buffered in stdout.lock. Therefore additional explicit flush
56- // is required here.
57- dest. flush ( ) ?;
5851 Ok ( ( ) )
5952}
0 commit comments