From e0e180aa9d9cac1e427ac23be49aca0c4059f755 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 15 Jan 2022 09:09:24 +0100 Subject: mod_cron: Allow for a small amount of timer drift If the timer activates a bit early then a task might be just a few seconds short of being allowed to run. This would run such a task rather than wait another hour. The value 0.5% chosen so that a weekly task does not run an entire hour earlier than last time. --- teal-src/plugins/mod_cron.tl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'teal-src/plugins/mod_cron.tl') diff --git a/teal-src/plugins/mod_cron.tl b/teal-src/plugins/mod_cron.tl index 581c8c0a..1375a195 100644 --- a/teal-src/plugins/mod_cron.tl +++ b/teal-src/plugins/mod_cron.tl @@ -78,7 +78,7 @@ function module.add_host(host_module : moduleapi) end local function should_run(when : frequency, last : integer) : boolean - return not last or last + periods[when] <= os.time(); + return not last or last + periods[when]*0.995 <= os.time(); end local function run_task(task : task_spec) -- cgit v1.2.3