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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user