Changeset

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
parents 10987:62355b801772
children 10989:b824fe9d0c8b
files plugins/mod_admin_shell.lua
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua	Tue Jun 30 02:31:29 2020 +0200
+++ b/plugins/mod_admin_shell.lua	Tue Jun 30 02:31:57 2020 +0200
@@ -1267,11 +1267,18 @@
 	local print = self.session.print;
 	local add_task = require"util.timer".add_task;
 	local h, params = add_task.h, add_task.params;
+	local function normalize_time(t)
+		return t;
+	end
+	local function format_time(t)
+		return os.date("%F %T", math.floor(normalize_time(t)));
+	end
 	if h then
 		print("-- util.timer");
 	elseif server.timer then
 		print("-- net.server.timer");
 		h = server.timer.add_task.timers;
+		normalize_time = server.timer.to_absolute_time or normalize_time;
 	end
 	if h then
 		for i, id in ipairs(h.ids) do
@@ -1286,7 +1293,7 @@
 			elseif params[id] then
 				cb = params[id].callback or cb;
 			end
-			print(os.date("%F %T", math.floor(t)), cb);
+			print(format_time(t), cb);
 		end
 	end
 	if server.event_base then
@@ -1301,7 +1308,7 @@
 	if h then
 		local next_time = h:peek();
 		if next_time then
-			return true, os.date("Next event at %F %T (in %%.6fs)", math.floor(next_time)):format(next_time - time.now());
+			return true, ("Next event at %s (in %.6fs)"):format(format_time(next_time), normalize_time(next_time) - time.now());
 		end
 	end
 	return true;