# HG changeset patch # User Marco Cirillo # Date 1329069585 0 # Node ID 121762432eb1caebcb53d3dd9cced8c38bbf6a31 # Parent a9249614b0fe672c8b4fb79df5835ad80148e2fb mod_register_json: remove cleanup function move it to a separate plugin. diff -r a9249614b0fe -r 121762432eb1 mod_register_json/mod_register_json.lua --- a/mod_register_json/mod_register_json.lua Sun Feb 12 16:35:54 2012 +0100 +++ b/mod_register_json/mod_register_json.lua Sun Feb 12 17:59:45 2012 +0000 @@ -113,32 +113,6 @@ end -- Set it up! -function regj_cleanup() -- it could be better if module:hook("module-unloaded", ...) actually worked. - module:log("debug", "Cleaning up handlers and stuff as module is being unloaded.") - for _, options in ipairs(ports) do - if options.port then - httpserver.new.http_servers[options.port].handlers[options.path or "register_account"] = nil - end - end - - -- if there are no handlers left clean and close the socket, doesn't work with server_event - local event = require "core.configmanager".get("*", "core", "use_libevent") - - if not event then - for _, options in ipairs(ports) do - if options.port and not next(httpserver.new.http_servers[options.port].handlers) then - httpserver.new.http_servers[options.port] = nil - if options.interface then - for _, value in ipairs(options.interface) do - if server.getserver(value, options.port) then server.removeserver(value, options.port) end - end - else if server.getserver("*", options.port) then server.removeserver("*", options.port) end end - end - end - end - - prosody.events.remove_handler("module-unloaded", regj_cleanup) -end function setup() for id, options in ipairs(ports) do @@ -147,7 +121,6 @@ else ports[id].port = 9443 end elseif options.port == 9280 and options.ssl then ports[id].port = 9443 end end httpserver.new_from_config(ports, handle_req, { base = "register_account" }) - prosody.events.add_handler("module-unloaded", regj_cleanup) end if prosody.start_time then -- already started