Software /
code /
prosody
Comparison
plugins/mod_admin_shell.lua @ 10988:9dcbbb1d12c3
mod_admin_shell: Handle server_epoll using monotonic time internally
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 30 Jun 2020 02:31:57 +0200 |
parent | 10986:d585deb8c882 |
child | 11041:d00bfa75999d |
comparison
equal
deleted
inserted
replaced
10987:62355b801772 | 10988:9dcbbb1d12c3 |
---|---|
1265 | 1265 |
1266 function def_env.debug:timers() | 1266 function def_env.debug:timers() |
1267 local print = self.session.print; | 1267 local print = self.session.print; |
1268 local add_task = require"util.timer".add_task; | 1268 local add_task = require"util.timer".add_task; |
1269 local h, params = add_task.h, add_task.params; | 1269 local h, params = add_task.h, add_task.params; |
1270 local function normalize_time(t) | |
1271 return t; | |
1272 end | |
1273 local function format_time(t) | |
1274 return os.date("%F %T", math.floor(normalize_time(t))); | |
1275 end | |
1270 if h then | 1276 if h then |
1271 print("-- util.timer"); | 1277 print("-- util.timer"); |
1272 elseif server.timer then | 1278 elseif server.timer then |
1273 print("-- net.server.timer"); | 1279 print("-- net.server.timer"); |
1274 h = server.timer.add_task.timers; | 1280 h = server.timer.add_task.timers; |
1281 normalize_time = server.timer.to_absolute_time or normalize_time; | |
1275 end | 1282 end |
1276 if h then | 1283 if h then |
1277 for i, id in ipairs(h.ids) do | 1284 for i, id in ipairs(h.ids) do |
1278 local t, cb = h.priorities[i], h.items[id]; | 1285 local t, cb = h.priorities[i], h.items[id]; |
1279 if not params then | 1286 if not params then |
1284 cb = cb.timer_callback or cb; | 1291 cb = cb.timer_callback or cb; |
1285 end | 1292 end |
1286 elseif params[id] then | 1293 elseif params[id] then |
1287 cb = params[id].callback or cb; | 1294 cb = params[id].callback or cb; |
1288 end | 1295 end |
1289 print(os.date("%F %T", math.floor(t)), cb); | 1296 print(format_time(t), cb); |
1290 end | 1297 end |
1291 end | 1298 end |
1292 if server.event_base then | 1299 if server.event_base then |
1293 local count = 0; | 1300 local count = 0; |
1294 for _, v in pairs(debug.getregistry()) do | 1301 for _, v in pairs(debug.getregistry()) do |
1299 print(count .. " libevent callbacks"); | 1306 print(count .. " libevent callbacks"); |
1300 end | 1307 end |
1301 if h then | 1308 if h then |
1302 local next_time = h:peek(); | 1309 local next_time = h:peek(); |
1303 if next_time then | 1310 if next_time then |
1304 return true, os.date("Next event at %F %T (in %%.6fs)", math.floor(next_time)):format(next_time - time.now()); | 1311 return true, ("Next event at %s (in %.6fs)"):format(format_time(next_time), normalize_time(next_time) - time.now()); |
1305 end | 1312 end |
1306 end | 1313 end |
1307 return true; | 1314 return true; |
1308 end | 1315 end |
1309 | 1316 |