Skip to content

Commit 6aeec70

Browse files
committed
test(server): fix reading from socket in maybe_notify when state is closed
1 parent 1a9f264 commit 6aeec70

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/http/conn.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,12 @@ where I: AsyncRead + AsyncWrite,
211211
//
212212
// When writing finishes, we need to wake the task up in case there
213213
// is more reading that can be done, to start a new message.
214-
match self.state.reading {
214+
let wants_read = match self.state.reading {
215215
Reading::Body(..) |
216216
Reading::KeepAlive => return,
217-
Reading::Init |
218-
Reading::Closed => (),
219-
}
217+
Reading::Init => true,
218+
Reading::Closed => false,
219+
};
220220

221221
match self.state.writing {
222222
Writing::Continue(..) |
@@ -228,10 +228,13 @@ where I: AsyncRead + AsyncWrite,
228228
}
229229

230230
if !self.io.is_read_blocked() {
231-
if self.io.read_buf().is_empty() {
231+
if wants_read && self.io.read_buf().is_empty() {
232232
match self.io.read_from_io() {
233233
Ok(Async::Ready(_)) => (),
234-
Ok(Async::NotReady) => return,
234+
Ok(Async::NotReady) => {
235+
trace!("maybe_notify; read_from_io blocked");
236+
return
237+
},
235238
Err(e) => {
236239
trace!("maybe_notify read_from_io error: {}", e);
237240
self.state.close();

0 commit comments

Comments
 (0)