# HG changeset patch # User Kim Alvefur # Date 1613507619 -3600 # Node ID 2f5e52d6792865af1df7fc3814c985c7f58f777e # Parent 0a56dc6c61af40c441dd89888ca9cd54b88b9c4f mod_smacks: Do ask for acks while in CSI inactive mode, but less frequent Otherwise the unacked stanza queue just grows forever diff -r 0a56dc6c61af -r 2f5e52d67928 mod_smacks/mod_smacks.lua --- a/mod_smacks/mod_smacks.lua Tue Feb 16 21:29:27 2021 +0100 +++ b/mod_smacks/mod_smacks.lua Tue Feb 16 21:33:39 2021 +0100 @@ -39,6 +39,7 @@ local s2s_smacks = module:get_option_boolean("smacks_enabled_s2s", false); local s2s_resend = module:get_option_boolean("smacks_s2s_resend", false); local max_unacked_stanzas = module:get_option_number("smacks_max_unacked_stanzas", 0); +local max_inactive_unacked_stanzas = module:get_option_number("smacks_max_inactive_unacked_stanzas", 256); local delayed_ack_timeout = module:get_option_number("smacks_max_ack_delay", 30); local max_hibernated_sessions = module:get_option_number("smacks_max_hibernated_sessions", 10); local max_old_sessions = module:get_option_number("smacks_max_old_sessions", 10); @@ -162,12 +163,16 @@ 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)); - if session.awaiting_ack == nil and not session.hibernating and session.state ~= "inactive" then + 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 is really sent (e.g. inside timer), preventing any -- further requests until a higher h-value would be expected. -- session.log("debug", "*** SMACKS(2) ***: #queue=%s, max_unacked_stanzas=%s, expected_h=%s, last_requested_h=%s", tostring(#queue), tostring(max_unacked_stanzas), tostring(expected_h), tostring(session.last_requested_h)); - if (#queue > max_unacked_stanzas and expected_h ~= session.last_requested_h) or force then + if (#queue > max_unacked and expected_h ~= session.last_requested_h) or force then session.log("debug", "Queuing (in a moment) from %s - #queue=%d", reason, #queue); session.awaiting_ack = false; session.awaiting_ack_timer = stoppable_timer(1e-06, function ()