Software /
code /
prosody
Changeset
12086:1dc00ca6ee9d 0.11
mod_pep: Limit possible growth of number of pubsub services
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 04 Nov 2021 00:35:44 +0100 |
parents | 12085:1d213c6f781b |
children | 12087:19f67d44ec37 |
files | plugins/mod_pep.lua |
diffstat | 1 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_pep.lua Thu Nov 04 00:33:58 2021 +0100 +++ b/plugins/mod_pep.lua Thu Nov 04 00:35:44 2021 +0100 @@ -18,8 +18,20 @@ local empty_set = set_new(); +-- username -> object passed to module:add_items() +local pep_service_items = {}; + +-- size of caches with full pubsub service objects +local service_cache_size = module:get_option_number("pep_service_cache_size", 1000); + -- username -> util.pubsub service object -local services = {}; +local services = cache.new(service_cache_size, function (username, _) + local item = pep_service_items[username]; + pep_service_items[username] = nil; + if item then + module:remove_item("pep-service", item); + end +end):table(); -- username -> recipient -> set of nodes local recipients = {}; @@ -202,7 +214,9 @@ check_node_config = check_node_config; }); services[username] = service; - module:add_item("pep-service", { service = service, jid = user_bare }); + local item = { service = service, jid = user_bare } + pep_service_items[username] = item; + module:add_item("pep-service", item); return service; end