From 39bfc042b07e19a77502c5991645d4d21664b76c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 11 Mar 2020 18:07:03 +0100 Subject: net.server_epoll: Fix indentation Some lines seem to have gotten the wrong indentation, possibly caused by Meld which often ignores lines with only whitespace changes and leaves their previous indentation. --- net/server_epoll.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/server_epoll.lua b/net/server_epoll.lua index 0c03ae15..2182d56a 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -102,7 +102,7 @@ local function runtimers(next_delay, min_wait) if peek > now then next_delay = peek - now; break; - end + end local _, timer, id = timers:pop(); local ok, ret = pcall(timer[2], now); @@ -110,10 +110,10 @@ local function runtimers(next_delay, min_wait) local next_time = now+ret; timer[1] = next_time; timers:insert(timer, next_time); - end + end peek = timers:peek(); - end + end if peek == nil then return next_delay; end -- cgit v1.2.3 From 01650eaf062645981632f7c8499ca9cf1583cc79 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 11 Mar 2020 21:15:01 +0100 Subject: 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. --- plugins/mod_mam/mod_mam.lua | 6 +++++- plugins/mod_muc_mam.lua | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index 295d90e1..e7d89a95 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -362,7 +362,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 users = {}; local cut_off = datestamp(os.time() - cleanup_after); for date in cleanup_storage:users() do @@ -391,6 +392,9 @@ if cleanup_after ~= "never" then 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); end); 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); -- cgit v1.2.3