batch_timeout: fix overflowing subtraction (#1976)
This commit is contained in:
parent
c221108916
commit
1fc5ba63fa
@ -324,10 +324,10 @@ impl TimerStruct {
|
||||
pub fn unset_timer(&mut self) {
|
||||
if self.batch_mode {
|
||||
unsafe {
|
||||
let elapsed = current_time() - self.tmout_start_time;
|
||||
let elapsed = current_time().saturating_sub(self.tmout_start_time);
|
||||
// elapsed may be > than tmout in case of received but ingored signal
|
||||
if elapsed > self.exec_tmout
|
||||
|| self.exec_tmout - elapsed < self.avg_exec_time * self.avg_mul_k
|
||||
|| self.exec_tmout.saturating_sub(elapsed) < self.avg_exec_time * self.avg_mul_k
|
||||
{
|
||||
let disarmed: libc::itimerspec = zeroed();
|
||||
libc::timer_settime(self.timerid, 0, addr_of!(disarmed), null_mut());
|
||||
|
Loading…
x
Reference in New Issue
Block a user