Mercurial > prosody-modules
diff mod_smacks/mod_smacks.lua @ 4637:242251ce1036
mod_smacks: Use 'smacks_max_inactive_unacked_stanzas' when inactive and no timer
This separate limit should probably apply also when it somehow doesn't
have a timer set.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 28 Jul 2021 16:06:03 +0200 |
parents | ab7dc5c5c782 |
children | edbd84bbd8fb |
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua Thu Jul 29 17:23:08 2021 +0200 +++ b/mod_smacks/mod_smacks.lua Wed Jul 28 16:06:03 2021 +0200 @@ -163,11 +163,11 @@ local queue = session.outgoing_stanza_queue; local expected_h = session.last_acknowledged_stanza + #queue; -- session.log("debug", "*** SMACKS(1) ***: awaiting_ack=%s, hibernating=%s", tostring(session.awaiting_ack), tostring(session.hibernating)); + local max_unacked = max_unacked_stanzas; + if session.state == "inactive" then + max_unacked = max_inactive_unacked_stanzas; + end if session.awaiting_ack == nil and not session.hibernating then - local max_unacked = max_unacked_stanzas; - if session.state == "inactive" then - max_unacked = max_inactive_unacked_stanzas; - end -- this check of last_requested_h prevents ack-loops if missbehaving clients report wrong -- stanza counts. it is set when an <r> is really sent (e.g. inside timer), preventing any -- further requests until a higher h-value would be expected. @@ -200,7 +200,7 @@ -- and there isn't already a timer for this event running. -- If we wouldn't do this, stanzas added to the queue after the first "smacks-ack-delayed"-event -- would not trigger this event (again). - if #queue > max_unacked_stanzas and session.awaiting_ack and session.delayed_ack_timer == nil then + if #queue > max_unacked and session.awaiting_ack and session.delayed_ack_timer == nil then session.log("debug", "Calling delayed_ack_function directly (still waiting for ack)"); delayed_ack_function(session, stanza); -- this is the only new stanza in the queue --> provide it to other modules end