don't panick on time subtraction failure (#141)

On some machines, the system clock can be faulty and start_time maybe
actually be after the end time. This causes a panic, instead gracefully
just put a None time in `self.last_runtime`
This commit is contained in:
Gal Tashma 2021-06-01 19:02:27 +03:00 committed by GitHub
parent 1b755036ad
commit ad9a2faaea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,7 +90,7 @@ impl<EM, I, S, Z> HasExecHooks<EM, I, S, Z> for TimeObserver {
_mgr: &mut EM,
_input: &I,
) -> Result<(), Error> {
self.last_runtime = Some(current_time() - self.start_time);
self.last_runtime = current_time().checked_sub(self.start_time);
Ok(())
}
}