aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/watchdog.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/util/watchdog.lua b/util/watchdog.lua
index 1d30f22b..6eb2e602 100644
--- a/util/watchdog.lua
+++ b/util/watchdog.lua
@@ -1,6 +1,5 @@
local timer = require "util.timer";
local setmetatable = setmetatable;
-local os_time = os.time;
local _ENV = nil;
-- luacheck: std none
@@ -15,16 +14,18 @@ local function new(timeout, callback)
timer_id = nil;
}, watchdog_mt);
- watchdog.timer_id = timer.add_task(timeout+1, function ()
- return watchdog:callback();
- end);
+ watchdog:reset(); -- Kick things off
return watchdog;
end
function watchdog_methods:reset()
if self.timer_id then
- timer.reschedule(self.timer_id, self.timeout);
+ timer.reschedule(self.timer_id, self.timeout+1);
+ else
+ self.timer_id = timer.add_task(self.timeout+1, function ()
+ return self:callback();
+ end);
end
end