Changeset

9765:5253555128ec

Merge with jonas
author Kim Alvefur <zash@zash.se>
date Sun, 06 Jan 2019 12:19:23 +0100
parents 9764:2f4240bfd147 (diff) 9761:8e83f90bf96b (current diff)
children 9766:f40b9649e929
files
diffstat 5 files changed, 38 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_http_errors.lua	Sun Jan 06 11:28:54 2019 +0100
+++ b/plugins/mod_http_errors.lua	Sun Jan 06 12:19:23 2019 +0100
@@ -26,21 +26,24 @@
 <meta charset="utf-8">
 <title>{title}</title>
 <style>
-body{
-	margin-top:14%;
-	text-align:center;
-	background-color:#F8F8F8;
-	font-family:sans-serif;
+body {
+	margin-top : 14%;
+	text-align : center;
+	background-color : #F8F8F8;
+	font-family : sans-serif
 }
-h1{
-	font-size:xx-large;
+
+h1 {
+	font-size : xx-large
 }
-p{
-	font-size:x-large;
+
+p {
+	font-size : x-large
 }
+
 p+p {
-	font-size:large;
-	font-family:courier;
+	font-size : large;
+	font-family : courier
 }
 </style>
 </head>
--- a/plugins/mod_mam/mod_mam.lua	Sun Jan 06 11:28:54 2019 +0100
+++ b/plugins/mod_mam/mod_mam.lua	Sun Jan 06 12:19:23 2019 +0100
@@ -351,19 +351,25 @@
 	function schedule_cleanup(username, date)
 		cleanup_map:set(date or datestamp(), username, true);
 	end
+	local cleanup_time = module:measure("cleanup", "times");
 
 	cleanup_runner = require "util.async".runner(function ()
+		local cleanup_done = cleanup_time();
 		local users = {};
 		local cut_off = datestamp(os.time() - cleanup_after);
 		for date in cleanup_storage:users() do
-			if date < cut_off then
+			if date <= cut_off then
 				module:log("debug", "Messages from %q should be expired", date);
 				local messages_this_day = cleanup_storage:get(date);
 				if messages_this_day then
 					for user in pairs(messages_this_day) do
 						users[user] = true;
 					end
-					cleanup_storage:set(date, nil);
+					if date < cut_off then
+						-- Messages from the same day as the cut-off might not have expired yet,
+						-- but all earlier will have, so clear storage for those days.
+						cleanup_storage:set(date, nil);
+					end
 				end
 			end
 		end
@@ -376,6 +382,7 @@
 			end
 		end
 		module:log("info", "Deleted %d expired messages for %d users", sum, num_users);
+		cleanup_done();
 	end);
 
 	cleanup_task = module:add_timer(1, function ()
--- a/plugins/mod_posix.lua	Sun Jan 06 11:28:54 2019 +0100
+++ b/plugins/mod_posix.lua	Sun Jan 06 12:19:23 2019 +0100
@@ -172,7 +172,7 @@
 		signal.signal("SIGHUP", function ()
 			module:log("info", "Received SIGHUP");
 			prosody.reload_config();
-			prosody.reopen_logfiles();
+			-- this also reloads logging
 		end);
 
 		signal.signal("SIGINT", function ()
--- a/util/http.lua	Sun Jan 06 11:28:54 2019 +0100
+++ b/util/http.lua	Sun Jan 06 12:19:23 2019 +0100
@@ -6,24 +6,25 @@
 --
 
 local format, char = string.format, string.char;
-local pairs, ipairs, tonumber = pairs, ipairs, tonumber;
+local pairs, ipairs = pairs, ipairs;
 local t_insert, t_concat = table.insert, table.concat;
 
+local url_codes = {};
+for i = 0, 255 do
+	local c = char(i);
+	local u = format("%%%02x", i);
+	url_codes[c] = u;
+	url_codes[u] = c;
+end
 local function urlencode(s)
-	return s and (s:gsub("[^a-zA-Z0-9.~_-]", function (c) return format("%%%02x", c:byte()); end));
+	return s and (s:gsub("[^a-zA-Z0-9.~_-]", url_codes));
 end
 local function urldecode(s)
-	return s and (s:gsub("%%(%x%x)", function (c) return char(tonumber(c,16)); end));
+	return s and (s:gsub("%%%x%x", url_codes));
 end
 
 local function _formencodepart(s)
-	return s and (s:gsub("%W", function (c)
-		if c ~= " " then
-			return format("%%%02x", c:byte());
-		else
-			return "+";
-		end
-	end));
+	return s and (urlencode(s):gsub("%%20", "+"));
 end
 
 local function formencode(form)
--- a/util/startup.lua	Sun Jan 06 11:28:54 2019 +0100
+++ b/util/startup.lua	Sun Jan 06 12:19:23 2019 +0100
@@ -87,6 +87,9 @@
 	-- Initialize logging
 	local loggingmanager = require "core.loggingmanager"
 	loggingmanager.reload_logging();
+	prosody.events.add_handler("config-reloaded", function ()
+		prosody.events.fire_event("reopen-log-files");
+	end);
 	prosody.events.add_handler("reopen-log-files", function ()
 		loggingmanager.reload_logging();
 		prosody.events.fire_event("logging-reloaded");