aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-01-27 22:10:11 +0100
committerKim Alvefur <zash@zash.se>2021-01-27 22:10:11 +0100
commit2cff8727c77948d6453474e8fb02e33d42d795d0 (patch)
tree1d91938bc0684ee100a075ef13e4bdc001afd556 /plugins
parent395de7cde5b3b2134df24fbf7b03e4bcba2c1af2 (diff)
downloadprosody-2cff8727c77948d6453474e8fb02e33d42d795d0.tar.gz
prosody-2cff8727c77948d6453474e8fb02e33d42d795d0.zip
mod_http_file_share: Insert pauses to avoid blocknig for long periods
Similar to the mod_mam cleanup job
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_http_file_share.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua
index 090a056a..477252db 100644
--- a/plugins/mod_http_file_share.lua
+++ b/plugins/mod_http_file_share.lua
@@ -263,6 +263,12 @@ if expiry >= 0 and not external_base_url then
local async = require "util.async";
local ENOENT = require "util.pposix".ENOENT;
+ local function sleep(t)
+ local wait, done = async.waiter();
+ module:add_timer(t, done)
+ wait();
+ end
+
local reaper_task = async.runner(function(boundary_time)
local iter, total = assert(uploads:find(nil, {["end"] = boundary_time; total = true}));
@@ -280,9 +286,11 @@ if expiry >= 0 and not external_base_url then
obsolete_files:push(get_filename(slot_id));
end
+ sleep(0.1);
local n = 0;
obsolete_files:filter(function(filename)
n = n + 1;
+ if i % 100 == 0 then sleep(0.1); end
local deleted, err, errno = os.remove(filename);
if deleted or errno == ENOENT then
return false;