Mercurial > prosody-modules
changeset 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 | 7f3ad8a5b2ab |
| children | d81bb13c0e87 |
| files | mod_firewall/definitions.lib.lua |
| diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
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;
