File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,7 @@ where
144
144
#[ pin]
145
145
writer: W ,
146
146
amt: u64 ,
147
+ reader_eof: bool
147
148
}
148
149
}
149
150
@@ -156,13 +157,20 @@ where
156
157
157
158
fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
158
159
let mut this = self . project ( ) ;
160
+
159
161
loop {
160
- let buffer = futures_core:: ready!( this. reader. as_mut( ) . poll_fill_buf( cx) ) ?;
161
- if buffer. is_empty ( ) {
162
+ if * this. reader_eof {
162
163
futures_core:: ready!( this. writer. as_mut( ) . poll_flush( cx) ) ?;
163
164
return Poll :: Ready ( Ok ( * this. amt ) ) ;
164
165
}
165
166
167
+ let buffer = futures_core:: ready!( this. reader. as_mut( ) . poll_fill_buf( cx) ) ?;
168
+
169
+ if buffer. is_empty ( ) {
170
+ * this. reader_eof = true ;
171
+ continue ;
172
+ }
173
+
166
174
let i = futures_core:: ready!( this. writer. as_mut( ) . poll_write( cx, buffer) ) ?;
167
175
if i == 0 {
168
176
return Poll :: Ready ( Err ( io:: ErrorKind :: WriteZero . into ( ) ) ) ;
@@ -176,6 +184,7 @@ where
176
184
let future = CopyFuture {
177
185
reader : BufReader :: new ( reader) ,
178
186
writer,
187
+ reader_eof : false ,
179
188
amt : 0 ,
180
189
} ;
181
190
future. await . context ( || String :: from ( "io::copy failed" ) )
You can’t perform that action at this time.
0 commit comments