fix(conn): handle when pre-emptive flushing closes the write state

Closes #1391
This commit is contained in:
Sean McArthur
2017-12-06 14:50:13 -08:00
parent eb9590e3da
commit 8f938d97e7

View File

@@ -196,8 +196,9 @@ where I: AsyncRead + AsyncWrite,
}
},
Reading::Init | Reading::KeepAlive | Reading::Closed => unreachable!()
_ => unreachable!("read_body invalid state: {:?}", self.state.reading),
};
self.state.reading = reading;
ret
}
@@ -324,6 +325,14 @@ where I: AsyncRead + AsyncWrite,
if self.has_queued_body() {
try!(self.flush());
if !self.can_write_body() {
if chunk.as_ref().map(|c| c.as_ref().len()).unwrap_or(0) == 0 {
return Ok(AsyncSink::NotReady(chunk));
} else {
return Ok(AsyncSink::Ready);
}
}
}
let state = match self.state.writing {
@@ -369,8 +378,9 @@ where I: AsyncRead + AsyncWrite,
}
}
},
_ => unreachable!(),
_ => unreachable!("write_body invalid state: {:?}", self.state.writing),
};
self.state.writing = state;
Ok(AsyncSink::Ready)
}