Automated merge with http://waqas.ath.cx:8000/

Wed, 07 Jan 2009 15:14:24 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 07 Jan 2009 15:14:24 +0000
changeset 675
cc82394fea22
parent 674
4f506c627b49 (diff)
parent 672
7db1044d2fab (current diff)
child 676
5e2dfeba1f14

Automated merge with http://waqas.ath.cx:8000/

core/modulemanager.lua file | annotate | diff | comparison | revisions
--- a/core/componentmanager.lua	Sun Jan 04 02:55:59 2009 +0000
+++ b/core/componentmanager.lua	Wed Jan 07 15:14:24 2009 +0000
@@ -21,7 +21,8 @@
 
 
 local log = require "util.logger".init("componentmanager");
-local module_load = require "core.modulemanager".load;
+local module_load = require "core.modulemanager".load;
+local module_unload = require "core.modulemanager".unload;
 local jid_split = require "util.jid".split;
 local hosts = hosts;
 
@@ -56,5 +57,17 @@
 		log("error", "Attempt to set component for existing host: "..host);
 	end
 end
+
+function deregister_component(host, component)
+	if components[host] then
+		module_unload(host, "dialback");
+		components[host] = nil;
+		hosts[host] = nil;
+		log("debug", "component removed: "..host);
+		return true;
+	else
+		log("error", "Attempt to remove component for non-existing host: "..host);
+	end
+end
 
 return _M;
--- a/core/modulemanager.lua	Sun Jan 04 02:55:59 2009 +0000
+++ b/core/modulemanager.lua	Wed Jan 07 15:14:24 2009 +0000
@@ -35,6 +35,7 @@
 local t_insert = table.insert;
 local type = type;
 local next = next;
+local rawget = rawget;
 
 local tostring, print = tostring, print;
 
@@ -136,12 +137,12 @@
 	local mod = modulemap[host] and modulemap[host][name];
 	if not mod then return nil, "module-not-loaded"; end
 	
-	--[[if type(mod.unload) == "function" then
-		local ok, err = pcall(mod.unload, ...)
+	if type(rawget(mod, "unload")) == "function" then
+		local ok, err = pcall(rawget(mod, "unload"), ...)
 		if (not ok) and err then
 			log("warn", "Non-fatal error unloading module '%s' from '%s': %s", name, host, err);
 		end
-	end]]
+	end
 	modulemap[host][name] = nil;
 	features_table:remove(host, name);
 	local params = handler_table:get(host, name); -- , {module.host, origin_type, tag, xmlns}

mercurial