File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,12 +159,14 @@ impl MultiWriter {
159159 // https://github.com/rust-lang/rust/blob/2feb91181882e525e698c4543063f4d0296fcf91/library/std/src/sys/io/mod.rs#L44
160160 const BUF_SIZE : usize = 8 * 1024 ;
161161 let mut buffer = [ 0u8 ; BUF_SIZE ] ;
162- // fast-path for small input
163- match input. read ( & mut buffer) {
164- Ok ( 0 ) => return Ok ( ( ) ) , // end of file
165- Ok ( received) => self . write_flush ( & buffer[ ..received] ) ?,
166- Err ( e) if e. kind ( ) != ErrorKind :: Interrupted => return Err ( e) ,
167- _ => { }
162+ // fast-path for small input. needs 2+ read to catch end of file
163+ for _ in 0 ..2 {
164+ match input. read ( & mut buffer) {
165+ Ok ( 0 ) => return Ok ( ( ) ) , // end of file
166+ Ok ( received) => self . write_flush ( & buffer[ ..received] ) ?,
167+ Err ( e) if e. kind ( ) != ErrorKind :: Interrupted => return Err ( e) ,
168+ _ => { }
169+ }
168170 }
169171 // buffer is too small optimize for large input
170172 //stack array makes code path for smaller file slower
You can’t perform that action at this time.
0 commit comments