Changeset

4647:57a4f863e48f

mod_admin_telnet: module:load(): Fix 'global-module-already-loaded' errors when successfully loading a global module (fixes #228)
author Matthew Wild <mwild1@gmail.com>
date Sat, 21 Apr 2012 20:52:12 +0100
parents 4646:e0bd8587f2fb
children 4648:561ca78e0dec
files plugins/mod_admin_telnet.lua
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua	Sat Apr 21 20:39:52 2012 +0100
+++ b/plugins/mod_admin_telnet.lua	Sat Apr 21 20:52:12 2012 +0100
@@ -292,16 +292,22 @@
 	hosts = get_hosts_set(hosts);
 	
 	-- Load the module for each host
-	local ok, err, count = true, nil, 0;
+	local ok, err, count, mod = true, nil, 0, nil;
 	for host in hosts do
 		if (not mm.is_loaded(host, name)) then
-			ok, err = mm.load(host, name, config);
-			if not ok then
+			mod, err = mm.load(host, name, config);
+			if not mod then
 				ok = false;
+				if err == "global-module-already-loaded" then
+					if count > 0 then
+						ok, err, count = true, nil, 1;
+					end
+					break;
+				end
 				self.session.print(err or "Unknown error loading module");
 			else
 				count = count + 1;
-				self.session.print("Loaded for "..host);
+				self.session.print("Loaded for "..mod.module.host);
 			end
 		end
 	end