Comparison

plugins/mod_admin_telnet.lua @ 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
parent 4646:e0bd8587f2fb
child 4674:f44726a910a0
comparison
equal deleted inserted replaced
4646:e0bd8587f2fb 4647:57a4f863e48f
290 local mm = require "modulemanager"; 290 local mm = require "modulemanager";
291 291
292 hosts = get_hosts_set(hosts); 292 hosts = get_hosts_set(hosts);
293 293
294 -- Load the module for each host 294 -- Load the module for each host
295 local ok, err, count = true, nil, 0; 295 local ok, err, count, mod = true, nil, 0, nil;
296 for host in hosts do 296 for host in hosts do
297 if (not mm.is_loaded(host, name)) then 297 if (not mm.is_loaded(host, name)) then
298 ok, err = mm.load(host, name, config); 298 mod, err = mm.load(host, name, config);
299 if not ok then 299 if not mod then
300 ok = false; 300 ok = false;
301 if err == "global-module-already-loaded" then
302 if count > 0 then
303 ok, err, count = true, nil, 1;
304 end
305 break;
306 end
301 self.session.print(err or "Unknown error loading module"); 307 self.session.print(err or "Unknown error loading module");
302 else 308 else
303 count = count + 1; 309 count = count + 1;
304 self.session.print("Loaded for "..host); 310 self.session.print("Loaded for "..mod.module.host);
305 end 311 end
306 end 312 end
307 end 313 end
308 314
309 return ok, (ok and "Module loaded onto "..count.." host"..(count ~= 1 and "s" or "")) or ("Last error: "..tostring(err)); 315 return ok, (ok and "Module loaded onto "..count.." host"..(count ~= 1 and "s" or "")) or ("Last error: "..tostring(err));