Do not use Instant::now when zero reset streams are configured. (#537)
This allows to use `h2` on wasm platforms which lack an `Instant::now` implementation by setting the number of streams to 0 with: `h2::client::Builder::max_concurrent_reset_streams`.
This commit is contained in:
@@ -866,13 +866,15 @@ impl Recv {
|
||||
}
|
||||
|
||||
pub fn clear_expired_reset_streams(&mut self, store: &mut Store, counts: &mut Counts) {
|
||||
let now = Instant::now();
|
||||
let reset_duration = self.reset_duration;
|
||||
while let Some(stream) = self.pending_reset_expired.pop_if(store, |stream| {
|
||||
let reset_at = stream.reset_at.expect("reset_at must be set if in queue");
|
||||
now - reset_at > reset_duration
|
||||
}) {
|
||||
counts.transition_after(stream, true);
|
||||
if !self.pending_reset_expired.is_empty() {
|
||||
let now = Instant::now();
|
||||
let reset_duration = self.reset_duration;
|
||||
while let Some(stream) = self.pending_reset_expired.pop_if(store, |stream| {
|
||||
let reset_at = stream.reset_at.expect("reset_at must be set if in queue");
|
||||
now - reset_at > reset_duration
|
||||
}) {
|
||||
counts.transition_after(stream, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user