aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_admin_telnet.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-12-23 11:42:14 +0100
committerKim Alvefur <zash@zash.se>2015-12-23 11:42:14 +0100
commit9a33b25f7024bf0d89e1c74e0e7bff78ab486464 (patch)
tree18589ec973a7f682ff17f1ee1c1aa4294d9a168b /plugins/mod_admin_telnet.lua
parentd780096b2a3091e32b10f3cf8e5472864dfc7475 (diff)
downloadprosody-9a33b25f7024bf0d89e1c74e0e7bff78ab486464.tar.gz
prosody-9a33b25f7024bf0d89e1c74e0e7bff78ab486464.zip
mod_admin_telnet: Make timer:info command more robust
Diffstat (limited to 'plugins/mod_admin_telnet.lua')
-rw-r--r--plugins/mod_admin_telnet.lua29
1 files changed, 17 insertions, 12 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua
index aa7b10cb..02ba3ab0 100644
--- a/plugins/mod_admin_telnet.lua
+++ b/plugins/mod_admin_telnet.lua
@@ -339,31 +339,36 @@ end
def_env.timer = {};
function def_env.timer:info()
+ local socket = require "socket";
local print = self.session.print;
local add_task = require"util.timer".add_task;
local h, params = add_task.h, add_task.params;
- print("-- util.timer");
- for i, id in ipairs(h.ids) do
- if not params[id] then
- print(os.date("%F %T", h.priorities[i]), h.items[id]);
- elseif not params[id].callback then
- print(os.date("%F %T", h.priorities[i]), h.items[id], unpack(params[id]));
- else
- print(os.date("%F %T", h.priorities[i]), params[id].callback, unpack(params[id]));
+ if h then
+ print("-- util.timer");
+ for i, id in ipairs(h.ids) do
+ if not params[id] then
+ print(os.date("%F %T", h.priorities[i]), h.items[id]);
+ elseif not params[id].callback then
+ print(os.date("%F %T", h.priorities[i]), h.items[id], unpack(params[id]));
+ else
+ print(os.date("%F %T", h.priorities[i]), params[id].callback, unpack(params[id]));
+ end
end
end
if server.event_base then
local count = 0;
for k, v in pairs(debug.getregistry()) do
- if type(v) == "function" and v.callback == add_task._on_timer then
+ if type(v) == "function" and v.callback and v.callback == add_task._on_timer then
count = count + 1;
end
end
print(count .. " libevent callbacks");
end
- local next_time = h:peek();
- if next_time then
- return true, os.date("Next event at %F %T", next_time);
+ if h then
+ local next_time = h:peek();
+ if next_time then
+ return true, os.date("Next event at %F %T (in %%.6fs)", next_time):format(next_time - socket.gettime());
+ end
end
return true;
end