Software /
code /
prosody-modules
Changeset
405:fe4fdba21a23
mod_pubsub_feed: Kill the timer on module unload
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 27 Aug 2011 04:49:11 +0200 |
parents | 404:eb8b005d2a3d |
children | 406:a6d215c73c47 |
files | mod_pubsub_feed/mod_pubsub_feed.lua |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_pubsub_feed/mod_pubsub_feed.lua Thu Aug 25 12:22:48 2011 +0500 +++ b/mod_pubsub_feed/mod_pubsub_feed.lua Sat Aug 27 04:49:11 2011 +0200 @@ -52,6 +52,12 @@ -- TODO module:hook("config-reloaded", above loop); -- Also, keeping it somewhere persistent in order to avoid duplicated publishes? +-- Used to kill the timer +local module_unloaded = false; +function module.unload() + module_unloaded = true; +end + -- Thanks to Maranda for this local port, base, ssl = 5280, "callback", false; local ports = module:get_option("feeds_ports") or { port = port, base = base, ssl = ssl }; @@ -76,6 +82,7 @@ ["400"] = "Bad Request"; ["403"] = "Forbidden"; ["404"] = "Not Found"; + ["500"] = "Internal Server Error"; ["501"] = "Not Implemented"; }; @@ -162,6 +169,7 @@ end function refresh_feeds() + if module_unloaded then return end --module:log("debug", "Refreshing feeds"); for node, item in pairs(feed_list) do --FIXME Don't fetch feeds which have a subscription @@ -202,6 +210,11 @@ end function handle_http_request(method, body, request) + if module_unloaded then + module:log("warn", "Received a HTTP request after module unload"); + return http_response(500) + -- FIXME if this happens. + end --module:log("debug", "%s request to %s%s with body %s", method, request.url.path, request.url.query and "?" .. request.url.query or "", #body > 0 and body or "empty"); local query = request.url.query or {}; if query and type(query) == "string" then