Comparison

plugins/mod_http_file_share.lua @ 11802:3d411720e719

mod_http_file_share: Fix measuring how long periodic task take
author Kim Alvefur <zash@zash.se>
date Tue, 14 Sep 2021 15:33:39 +0200
parent 11794:5d925f340ae6
child 11853:ae5ac9830add
comparison
equal deleted inserted replaced
11801:ab0dfe9cbe69 11802:3d411720e719
446 local wait, done = async.waiter(); 446 local wait, done = async.waiter();
447 module:add_timer(t, done) 447 module:add_timer(t, done)
448 wait(); 448 wait();
449 end 449 end
450 450
451 local prune_start = module:measure("prune", "times");
452
451 local reaper_task = async.runner(function(boundary_time) 453 local reaper_task = async.runner(function(boundary_time)
452 local prune_done = module:measure("prune", "times"); 454 local prune_done = prune_start();
453 local iter, total = assert(uploads:find(nil, {["end"] = boundary_time; total = true})); 455 local iter, total = assert(uploads:find(nil, {["end"] = boundary_time; total = true}));
454 456
455 if total == 0 then 457 if total == 0 then
456 module:log("info", "No expired uploaded files to prune"); 458 module:log("info", "No expired uploaded files to prune");
457 prune_done(); 459 prune_done();
532 end 534 end
533 535
534 if total_storage_limit then 536 if total_storage_limit then
535 local async = require "util.async"; 537 local async = require "util.async";
536 538
539 local summary_start = module:measure("summary", "times");
540
537 local summarizer_task = async.runner(function() 541 local summarizer_task = async.runner(function()
538 local summary_done = module:measure("summary", "times"); 542 local summary_done = summary_start();
539 local iter = assert(uploads:find(nil)); 543 local iter = assert(uploads:find(nil));
540 544
541 local count, sum = 0, 0; 545 local count, sum = 0, 0;
542 for _, file in iter do 546 for _, file in iter do
543 sum = sum + tonumber(file.attr.size); 547 sum = sum + tonumber(file.attr.size);