Diff

core/modulemanager.lua @ 674:4f506c627b49

modulemanager: module.unload now gets called when modules are being unloaded
author Waqas Hussain <waqas20@gmail.com>
date Wed, 07 Jan 2009 20:03:59 +0500
parent 670:d5cf10b7fc44
child 675:cc82394fea22
line wrap: on
line diff
--- a/core/modulemanager.lua	Wed Jan 07 20:02:49 2009 +0500
+++ b/core/modulemanager.lua	Wed Jan 07 20:03:59 2009 +0500
@@ -35,6 +35,7 @@
 local t_insert = table.insert;
 local type = type;
 local next = next;
+local rawget = rawget;
 
 local tostring, print = tostring, print;
 
@@ -134,12 +135,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}