Skip to content

Commit

Permalink
Reset on recv_err if scheduled or EOS
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Apr 16, 2018
1 parent 040f391 commit 5210132
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/proto/streams/recv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ impl Recv {
/// Handle a received error
pub fn recv_err(&mut self, err: &proto::Error, stream: &mut Stream) {
// Receive an error
stream.state.recv_err(err);
stream.state.recv_err(err, stream.is_pending_send);

// If a receiver is waiting, notify it
stream.notify_send();
Expand Down
17 changes: 13 additions & 4 deletions src/proto/streams/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,22 @@ impl State {
}

/// We noticed a protocol error.
pub fn recv_err(&mut self, err: &proto::Error) {
///
/// # Arguments
/// - `err`: the protocol error that occurred.
/// - `queued`: true if this stream has frames in the pending send queue.
pub fn recv_err(&mut self, err: &proto::Error, queued: bool) {
use proto::Error::*;

match self.inner {
Closed(..) => {},
_ => {
trace!("recv_err; err={:?}", err);
// If the stream is already in a `Closed` state, do nothing,
// provided that there are no frames still in the send queue.
Closed(..) if !queued => {},
state => {
trace!(
"recv_err; err={:?}; state={:?}; queued={:?}",
err, state, queued
);
self.inner = Closed(match *err {
Proto(reason) => Cause::LocallyReset(reason),
Io(..) => Cause::Io,
Expand Down

0 comments on commit 5210132

Please sign in to comment.