Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid time operations that can panic #599

Merged
merged 1 commit into from Feb 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/proto/streams/recv.rs
Expand Up @@ -860,7 +860,10 @@ impl Recv {
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
// rust-lang/rust#86470 tracks a bug in the standard library where `Instant`
// subtraction can panic (because, on some platforms, `Instant` isn't actually
// monotonic). We use a saturating operation to avoid this panic here.
now.saturating_duration_since(reset_at) > reset_duration
}) {
counts.transition_after(stream, true);
}
Expand Down