From be020a55d61b2f046738d09093243462ddfdcaa2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 15 Apr 2020 07:53:36 -0700 Subject: [PATCH] Try to avoid panics on buggy (?) clocks Try to avoid panics with `Instant` by only performing infallible operations. This tweaks a comparison located in #8042 to use `Instant` comparisons rather than `Duration` comparisons which should hopefully eliminate a source of panics in the face of buggy (maybe?) clocks. I'm not sure whether this actually fixes the original issue, but seeing that we have a pretty low chance of the issue recurring, it's probably fine to go ahead and say... Closes #8042 --- src/cargo/core/package.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index b5d0df5a947..061e6c1e8ac 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -934,7 +934,7 @@ impl<'a, 'cfg> Downloads<'a, 'cfg> { } // If we've spent too long not actually receiving any data we time out. - if now - self.updated_at.get() > self.timeout.dur { + if now > self.updated_at.get() + self.timeout.dur { self.updated_at.set(now); let msg = format!( "failed to download any data for `{}` within {}s",