# HG changeset patch # User Kim Alvefur # Date 1314413351 -7200 # Node ID fe4fdba21a2346d78fd77a2a11ce3d3afbc21a3c # Parent eb8b005d2a3d198e26370280c5bf6463139ab207 mod_pubsub_feed: Kill the timer on module unload diff -r eb8b005d2a3d -r fe4fdba21a23 mod_pubsub_feed/mod_pubsub_feed.lua --- 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