Changeset

607:121762432eb1

mod_register_json: remove cleanup function move it to a separate plugin.
author Marco Cirillo <maranda@lightwitch.org>
date Sun, 12 Feb 2012 17:59:45 +0000
parents 606:a9249614b0fe
children 608:fb9a2ab8458a
files mod_register_json/mod_register_json.lua
diffstat 1 files changed, 0 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- 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