Software /
code /
prosody
Comparison
plugins/mod_muc_mam.lua @ 10682:62ef68f95b6f 0.11
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 11 Mar 2020 21:15:01 +0100 |
parent | 10670:5376f882cf82 |
child | 10683:2f0b7f1d5e75 |
child | 10814:e042b0c8b310 |
comparison
equal
deleted
inserted
replaced
10681:e531273341d3 | 10682:62ef68f95b6f |
---|---|
435 if ok then | 435 if ok then |
436 last_date:set(roomname, date); | 436 last_date:set(roomname, date); |
437 end | 437 end |
438 end | 438 end |
439 | 439 |
440 cleanup_runner = require "util.async".runner(function () | 440 local async = require "util.async"; |
441 cleanup_runner = async.runner(function () | |
441 local rooms = {}; | 442 local rooms = {}; |
442 local cut_off = datestamp(os.time() - cleanup_after); | 443 local cut_off = datestamp(os.time() - cleanup_after); |
443 for date in cleanup_storage:users() do | 444 for date in cleanup_storage:users() do |
444 if date <= cut_off then | 445 if date <= cut_off then |
445 module:log("debug", "Messages from %q should be expired", date); | 446 module:log("debug", "Messages from %q should be expired", date); |
464 sum = sum + (tonumber(ok) or 0); | 465 sum = sum + (tonumber(ok) or 0); |
465 else | 466 else |
466 cleanup_map:set(cut_off, room, true); | 467 cleanup_map:set(cut_off, room, true); |
467 module:log("error", "Could not delete messages for room '%s': %s", room, err); | 468 module:log("error", "Could not delete messages for room '%s': %s", room, err); |
468 end | 469 end |
470 local wait, done = async.waiter(); | |
471 module:add_timer(0.01, done); | |
472 wait(); | |
469 end | 473 end |
470 module:log("info", "Deleted %d expired messages for %d rooms", sum, num_rooms); | 474 module:log("info", "Deleted %d expired messages for %d rooms", sum, num_rooms); |
471 end); | 475 end); |
472 | 476 |
473 cleanup_task = module:add_timer(1, function () | 477 cleanup_task = module:add_timer(1, function () |