diff --git a/yamux/src/connection/stream.rs b/yamux/src/connection/stream.rs index 7a4893db..0ccc638f 100644 --- a/yamux/src/connection/stream.rs +++ b/yamux/src/connection/stream.rs @@ -550,6 +550,10 @@ impl Shared { let buffer_len = self.buffer.len(); let mut new_credit = bytes_received.saturating_sub(buffer_len); + if new_credit < self.window_max / 2 { + return None; + } + log::debug!( "received {} mb in {} seconds ({} mbit/s)", new_credit as f64 / 1024.0 / 1024.0, @@ -558,10 +562,6 @@ impl Shared { / self.last_window_update.elapsed().as_secs_f64() ); - if new_credit < self.window_max / 2 { - return None; - } - if let Some(rtt) = self.rtt.rtt() { if self.last_window_update.elapsed() < rtt * 2 { let previous_window_max = self.window_max;