Mercurial > prosody-modules
diff mod_firewall/definitions.lib.lua @ 6554:0002c727e918
mod_firewall: Use module:add_timer() for HTTP polling
This ensures that polling stops when the module is unloaded.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 24 May 2026 19:35:52 +0100 |
| parents | 7eec2bc67c26 |
| children |
line wrap: on
line diff
--- a/mod_firewall/definitions.lib.lua Sun May 24 19:30:31 2026 +0100 +++ b/mod_firewall/definitions.lib.lua Sun May 24 19:35:52 2026 +0100 @@ -5,7 +5,6 @@ local definition_handlers = {}; local http = require "net.http"; -local timer = require "util.timer"; local set = require"util.set"; local new_throttle = require "util.throttle".create; local hashes = require "util.hashes"; @@ -136,11 +135,14 @@ next_poll = retry_intervals[failure_count] or retry_intervals[#retry_intervals]; end if next_poll > 0 then - timer.add_task(next_poll+math.random(0, 60), update_list); + return next_poll + math.random(0, 60); end end); end - update_list(); + local delay = update_list(); + if delay then + module:add_timer(delay, update_list); + end end; add = function () end;
