Software /
code /
prosody-modules
Changeset
1408:ed2a9c00b5c4
mod_smacks: Impose a limit on number of unacked stanzas (Thanks Holger)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 07 May 2014 16:18:05 +0200 |
parents | 1407:b631c8a8b9e7 |
children | 1409:151aa00559d1 |
files | mod_smacks/mod_smacks.lua |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua Wed May 07 14:21:33 2014 +0200 +++ b/mod_smacks/mod_smacks.lua Wed May 07 16:18:05 2014 +0200 @@ -19,6 +19,7 @@ local resume_timeout = module:get_option_number("smacks_hibernation_time", 300); local s2s_smacks = module:get_option_boolean("smacks_enabled_s2s", false); +local max_queue_size = module:get_option_number("smacks_max_queue_size", 500); local max_unacked_stanzas = module:get_option_number("smacks_max_unacked_stanzas", 0); local core_process_stanza = prosody.core_process_stanza; local sessionmanager = require"core.sessionmanager"; @@ -90,6 +91,10 @@ cached_stanza = cached_stanza:tag("delay", { xmlns = xmlns_delay, from = session.host, stamp = datetime.datetime()}); end + if max_queue_size > 0 and #queue > max_queue_size then + session.log("warn", "Too many unacked stanzas"); + session:close{ condition = "policy-violation"; text = "Too many unacked stanzas"; }; + end queue[#queue+1] = cached_stanza; session.log("debug", "#queue = %d", #queue); end