Changeset

4444:2f5e52d67928

mod_smacks: Do ask for acks while in CSI inactive mode, but less frequent Otherwise the unacked stanza queue just grows forever
author Kim Alvefur <zash@zash.se>
date Tue, 16 Feb 2021 21:33:39 +0100
parents 4443:0a56dc6c61af
children 4445:e13eb0f851c8
files mod_smacks/mod_smacks.lua
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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 <r> 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 <r> (in a moment) from %s - #queue=%d", reason, #queue);
 			session.awaiting_ack = false;
 			session.awaiting_ack_timer = stoppable_timer(1e-06, function ()