mod_admin_telnet: Soft-reqire util.pposix for server:memory()
authorKim Alvefur <zash@zash.se>
Mon, 27 Oct 2014 11:12:08 +0100
changeset 6506 8437058c4226
parent 6504 71b6e8b48a12
child 6507 e1659f32852e
mod_admin_telnet: Soft-reqire util.pposix for server:memory()
plugins/mod_admin_telnet.lua
--- a/plugins/mod_admin_telnet.lua	Sun Oct 26 20:57:06 2014 +0100
+++ b/plugins/mod_admin_telnet.lua	Mon Oct 27 11:12:08 2014 +0100
@@ -27,6 +27,7 @@
 local cert_verify_identity = require "util.x509".verify_identity;
 local envload = require "util.envload".envload;
 local envloadfile = require "util.envload".envloadfile;
+local has_pposix, pposix = pcall(require, "util.pposix");
 
 local commands = module:shared("commands")
 local def_env = module:shared("env");
@@ -322,7 +323,7 @@
 end
 
 function def_env.server:memory()
-	if not pposix.meminfo then
+	if not has_pposix or not pposix.meminfo then
 		return true, "Lua is using "..collectgarbage("count");
 	end
 	local mem, lua_mem = pposix.meminfo(), collectgarbage("count");