Fix send flow control bug

The send stream state is transitioned before data is buffered. As such,
the stream state could be closed while there is still data to be sent.
This commit is contained in:
Carl Lerche
2017-08-25 07:07:21 -07:00
parent 63ba0073a4
commit 0c8a94aa11
5 changed files with 20 additions and 23 deletions

View File

@@ -213,6 +213,7 @@ impl State {
match self.inner {
Closed(..) => {}
_ => {
trace!("recv_err; err={:?}", err);
self.inner = Closed(match *err {
ConnectionError::Proto(reason) => Some(Cause::Proto(reason)),
ConnectionError::Io(..) => Some(Cause::Io),
@@ -264,16 +265,6 @@ impl State {
}
}
/// Returns true if the stream is in a state such that it could send data in
/// the future.
pub fn could_send_data(&self) -> bool {
match self.inner {
Open { .. } => true,
HalfClosedRemote(_) => true,
_ => false,
}
}
pub fn is_send_streaming(&self) -> bool {
match self.inner {
Open { local: Peer::Streaming, .. } => true,