Comparison

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
parent 4632:ab7dc5c5c782
child 4681:edbd84bbd8fb
comparison
equal deleted inserted replaced
4636:6bcccc63b542 4637:242251ce1036
161 161
162 local function request_ack_if_needed(session, force, reason, stanza) 162 local function request_ack_if_needed(session, force, reason, stanza)
163 local queue = session.outgoing_stanza_queue; 163 local queue = session.outgoing_stanza_queue;
164 local expected_h = session.last_acknowledged_stanza + #queue; 164 local expected_h = session.last_acknowledged_stanza + #queue;
165 -- session.log("debug", "*** SMACKS(1) ***: awaiting_ack=%s, hibernating=%s", tostring(session.awaiting_ack), tostring(session.hibernating)); 165 -- session.log("debug", "*** SMACKS(1) ***: awaiting_ack=%s, hibernating=%s", tostring(session.awaiting_ack), tostring(session.hibernating));
166 local max_unacked = max_unacked_stanzas;
167 if session.state == "inactive" then
168 max_unacked = max_inactive_unacked_stanzas;
169 end
166 if session.awaiting_ack == nil and not session.hibernating then 170 if session.awaiting_ack == nil and not session.hibernating then
167 local max_unacked = max_unacked_stanzas;
168 if session.state == "inactive" then
169 max_unacked = max_inactive_unacked_stanzas;
170 end
171 -- this check of last_requested_h prevents ack-loops if missbehaving clients report wrong 171 -- this check of last_requested_h prevents ack-loops if missbehaving clients report wrong
172 -- stanza counts. it is set when an <r> is really sent (e.g. inside timer), preventing any 172 -- stanza counts. it is set when an <r> is really sent (e.g. inside timer), preventing any
173 -- further requests until a higher h-value would be expected. 173 -- further requests until a higher h-value would be expected.
174 -- 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)); 174 -- 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));
175 if (#queue > max_unacked and expected_h ~= session.last_requested_h) or force then 175 if (#queue > max_unacked and expected_h ~= session.last_requested_h) or force then
198 198
199 -- Trigger "smacks-ack-delayed"-event if we added new (ackable) stanzas to the outgoing queue 199 -- Trigger "smacks-ack-delayed"-event if we added new (ackable) stanzas to the outgoing queue
200 -- and there isn't already a timer for this event running. 200 -- and there isn't already a timer for this event running.
201 -- If we wouldn't do this, stanzas added to the queue after the first "smacks-ack-delayed"-event 201 -- If we wouldn't do this, stanzas added to the queue after the first "smacks-ack-delayed"-event
202 -- would not trigger this event (again). 202 -- would not trigger this event (again).
203 if #queue > max_unacked_stanzas and session.awaiting_ack and session.delayed_ack_timer == nil then 203 if #queue > max_unacked and session.awaiting_ack and session.delayed_ack_timer == nil then
204 session.log("debug", "Calling delayed_ack_function directly (still waiting for ack)"); 204 session.log("debug", "Calling delayed_ack_function directly (still waiting for ack)");
205 delayed_ack_function(session, stanza); -- this is the only new stanza in the queue --> provide it to other modules 205 delayed_ack_function(session, stanza); -- this is the only new stanza in the queue --> provide it to other modules
206 end 206 end
207 end 207 end
208 208