File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -670,14 +670,19 @@ impl LockGuard<State> {
670
670
671
671
match self . mode {
672
672
Mode :: Idle => { }
673
+ Mode :: Reading ( 0 ) if self . cache . is_empty ( ) => {
674
+ // If the cache is empty in reading mode, the last operation didn't read any bytes,
675
+ // which indicates that it reached the end of the file. In this case we need to
676
+ // reset the mode to idle so that next time we try to read again, since the file
677
+ // may grow after the first EOF.
678
+ self . mode = Mode :: Idle ;
679
+ return Poll :: Ready ( Ok ( 0 ) ) ;
680
+ }
673
681
Mode :: Reading ( start) => {
674
682
// How many bytes in the cache are available for reading.
675
683
let available = self . cache . len ( ) - start;
676
684
677
- // If there is cached unconsumed data or if the cache is empty, we can read from
678
- // it. Empty cache in reading mode indicates that the last operation didn't read
679
- // any bytes, i.e. it reached the end of the file.
680
- if available > 0 || self . cache . is_empty ( ) {
685
+ if available > 0 {
681
686
// Copy data from the cache into the buffer.
682
687
let n = cmp:: min ( available, buf. len ( ) ) ;
683
688
buf[ ..n] . copy_from_slice ( & self . cache [ start..( start + n) ] ) ;
You can’t perform that action at this time.
0 commit comments