fix(client): prevent panicking when determine Expiration in pool
On some OSes, `Instant` would start counting 0 from the boot time. That would mean that any `Instant::now() - dur` soon after boot had a higher risk of overflowing. Now, the expiration is determined by calling `idle.elapsed()`, and comparing durations. Closes #1215
This commit is contained in:
		| @@ -260,16 +260,16 @@ impl<T: Clone> Future for Checkout<T> { | ||||
|     } | ||||
| } | ||||
|  | ||||
| struct Expiration(Option<Instant>); | ||||
| struct Expiration(Option<Duration>); | ||||
|  | ||||
| impl Expiration { | ||||
|     fn new(dur: Option<Duration>) -> Expiration { | ||||
|         Expiration(dur.map(|dur| Instant::now() - dur)) | ||||
|         Expiration(dur) | ||||
|     } | ||||
|  | ||||
|     fn expires(&self, instant: Instant) -> bool { | ||||
|         match self.0 { | ||||
|             Some(expire) => expire > instant, | ||||
|             Some(timeout) => instant.elapsed() > timeout, | ||||
|             None => false, | ||||
|         } | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user