Diff

plugins/mod_mam/mod_mam.lua @ 10683:2f0b7f1d5e75

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Wed, 11 Mar 2020 22:44:41 +0100
parent 10568:b6f93babebe8
parent 10682:62ef68f95b6f
child 10734:136c41a3d03c
line wrap: on
line diff
--- a/plugins/mod_mam/mod_mam.lua	Wed Mar 11 16:32:41 2020 +0000
+++ b/plugins/mod_mam/mod_mam.lua	Wed Mar 11 22:44:41 2020 +0100
@@ -403,7 +403,8 @@
 	end
 	local cleanup_time = module:measure("cleanup", "times");
 
-	cleanup_runner = require "util.async".runner(function ()
+	local async = require "util.async";
+	cleanup_runner = async.runner(function ()
 		local cleanup_done = cleanup_time();
 		local users = {};
 		local cut_off = datestamp(os.time() - cleanup_after);
@@ -433,6 +434,9 @@
 				cleanup_map:set(cut_off, user, true);
 				module:log("error", "Could not delete messages for user '%s': %s", user, err);
 			end
+			local wait, done = async.waiter();
+			module:add_timer(0.01, done);
+			wait();
 		end
 		module:log("info", "Deleted %d expired messages for %d users", sum, num_users);
 		cleanup_done();