aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_muc_mam.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-03-11 21:15:01 +0100
committerKim Alvefur <zash@zash.se>2020-03-11 21:15:01 +0100
commit650690f1e2e9c74d6f11c8ab629edc81973be443 (patch)
tree7c3921280ff31ed37d52b1c463f3df6c45aab331 /plugins/mod_muc_mam.lua
parent27849cec9eb1c12cf2930ee45a81abaec5809e60 (diff)
downloadprosody-650690f1e2e9c74d6f11c8ab629edc81973be443.tar.gz
prosody-650690f1e2e9c74d6f11c8ab629edc81973be443.zip
mod_mam,mod_muc_mam: Allow other work to be performed during archive cleanup (fixes #1504)
This lets Prosody handle socket related work between each step in the cleanup in order to prevent the server from being completely blocked during this. An async storage backend would not need this but those are currently rare.
Diffstat (limited to 'plugins/mod_muc_mam.lua')
-rw-r--r--plugins/mod_muc_mam.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/mod_muc_mam.lua b/plugins/mod_muc_mam.lua
index f7ea3136..5a01324d 100644
--- a/plugins/mod_muc_mam.lua
+++ b/plugins/mod_muc_mam.lua
@@ -437,7 +437,8 @@ if cleanup_after ~= "never" then
end
end
- cleanup_runner = require "util.async".runner(function ()
+ local async = require "util.async";
+ cleanup_runner = async.runner(function ()
local rooms = {};
local cut_off = datestamp(os.time() - cleanup_after);
for date in cleanup_storage:users() do
@@ -466,6 +467,9 @@ if cleanup_after ~= "never" then
cleanup_map:set(cut_off, room, true);
module:log("error", "Could not delete messages for room '%s': %s", room, err);
end
+ local wait, done = async.waiter();
+ module:add_timer(0.01, done);
+ wait();
end
module:log("info", "Deleted %d expired messages for %d rooms", sum, num_rooms);
end);