mirror of
https://github.com/bjc/prosody.git
synced 2025-04-03 21:27:38 +03:00
mod_http_file_share: Insert pauses to avoid blocknig for long periods
Similar to the mod_mam cleanup job
This commit is contained in:
parent
cdccf23854
commit
7b01925b09
1 changed files with 8 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue