File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,11 +120,13 @@ pub fn exec(mut bytes: Vec<u8>) -> io::Result<()> {
120120 if let Ok ( ( p_read, mut p_write) ) = pipe :: < true > ( MAX_ROOTLESS_PIPE_SIZE )
121121 && p_write. write_all ( bytes) . is_ok ( )
122122 {
123- // tee() cannot control offset. Check that output is pipe by tee
124- if safe_partial_send && tee ( & p_read, & stdout, MAX_ROOTLESS_PIPE_SIZE ) . is_ok ( ) {
123+ // tee() cannot control offset. But omit splice if it is possible
124+ if safe_partial_send {
125+ // fails if stdout is not a pipe
125126 while tee ( & p_read, & stdout, MAX_ROOTLESS_PIPE_SIZE ) . is_ok ( ) { }
126- } else if let Ok ( ( broker_read, broker_write) ) = pipe :: < true > ( MAX_ROOTLESS_PIPE_SIZE ) {
127- ' hybrid: while let Ok ( mut remain) = tee ( & p_read, & broker_write, MAX_ROOTLESS_PIPE_SIZE )
127+ }
128+ if let Ok ( ( broker_read, broker_write) ) = pipe :: < true > ( MAX_ROOTLESS_PIPE_SIZE ) {
129+ ' splice: while let Ok ( mut remain) = tee ( & p_read, & broker_write, MAX_ROOTLESS_PIPE_SIZE )
128130 {
129131 debug_assert ! ( remain == bytes. len( ) , "splice() should cleanup pipe" ) ;
130132 while remain > 0 {
@@ -133,7 +135,7 @@ pub fn exec(mut bytes: Vec<u8>) -> io::Result<()> {
133135 } else {
134136 // avoid output breakage with reduced remain even if it would not happen
135137 RawWriter ( stdout) . write_all ( & bytes[ bytes. len ( ) - remain..] ) ?;
136- break ' hybrid ;
138+ break ' splice ;
137139 }
138140 }
139141 }
You can’t perform that action at this time.
0 commit comments