aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-05-22 21:22:51 +0200
committerKim Alvefur <zash@zash.se>2018-05-22 21:22:51 +0200
commita012355b09e6415a7eb3b80bc5ebe5f0add650d2 (patch)
treec59bbcc634afedf783f5489c9b2d6747d70461fb /plugins/muc
parent6e658ef651e451f771d65fac290ad34917812dc4 (diff)
downloadprosody-a012355b09e6415a7eb3b80bc5ebe5f0add650d2.tar.gz
prosody-a012355b09e6415a7eb3b80bc5ebe5f0add650d2.zip
MUC: Add support for an optional hard limit on number of rooms (fixes #766)
Diffstat (limited to 'plugins/muc')
-rw-r--r--plugins/muc/mod_muc.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua
index 979aed8c..10de8c95 100644
--- a/plugins/muc/mod_muc.lua
+++ b/plugins/muc/mod_muc.lua
@@ -124,8 +124,15 @@ local function room_save(room, forced, savestate)
end
end
+local max_rooms = module:get_option_number("muc_max_rooms");
+local max_live_rooms = module:get_option_number("muc_room_cache_size", 100);
+
local eviction_hit_rate = module:measure("room_eviction", "rate");
-local rooms = cache.new(module:get_option_number("muc_room_cache_size", 100), function (jid, room)
+local rooms = cache.new(max_rooms or max_live_rooms, function (jid, room)
+ if max_rooms then
+ module:log("info", "Room limit of %d reached, no new rooms allowed");
+ return false;
+ end
module:log("debug", "Evicting room %s", jid);
eviction_hit_rate();
room_items_cache[room.jid] = room:get_public() and room:get_name() or nil;