Skip to content

Commit

Permalink
Auto merge of #8114 - alexcrichton:change-condition, r=Eh2406
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Apr 15, 2020
2 parents 74e3a7d + be020a5 commit f22d17c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f22d17c

Please sign in to comment.