Changeset

12522:1671cb924002 0.12

mod_smacks: Fix to use current method of counting acked stanzas Fixes #1757 These places seem to have been left since e62025f949f9 The logic around expected_h in should_ack() misbehaved, always comparing with 0 + unacked instead of acked + unacked.
author Kim Alvefur <zash@zash.se>
date Thu, 26 May 2022 17:38:55 +0200
parents 12520:bb5f772b3189
children 12523:d2177cb5a766 12525:8087f5357f53
files plugins/mod_smacks.lua
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_smacks.lua	Thu May 26 13:03:58 2022 +0200
+++ b/plugins/mod_smacks.lua	Thu May 26 17:38:55 2022 +0200
@@ -143,7 +143,7 @@
 	if session.awaiting_ack then return end -- already waiting
 	if force then return force end
 	local queue = session.outgoing_stanza_queue;
-	local expected_h = session.last_acknowledged_stanza + queue:count_unacked();
+	local expected_h = queue:count_acked() + queue:count_unacked();
 	local max_unacked = max_unacked_stanzas;
 	if session.state == "inactive" then
 		max_unacked = max_inactive_unacked_stanzas;
@@ -161,7 +161,7 @@
 	if session.destroyed then return end -- sending something can trigger destruction
 	session.awaiting_ack = true;
 	-- expected_h could be lower than this expression e.g. more stanzas added to the queue meanwhile)
-	session.last_requested_h = session.last_acknowledged_stanza + queue:count_unacked();
+	session.last_requested_h = queue:count_acked() + queue:count_unacked();
 	session.log("debug", "Sending <r> (inside timer, after send) from %s - #queue=%d", reason, queue:count_unacked());
 	if not session.delayed_ack_timer then
 		session.delayed_ack_timer = timer.add_task(delayed_ack_timeout, function()
@@ -223,7 +223,6 @@
 local function wrap_session_out(session, resume)
 	if not resume then
 		session.outgoing_stanza_queue = smqueue.new(queue_size);
-		session.last_acknowledged_stanza = 0;
 	end
 
 	add_filter(session, "stanzas/out", outgoing_stanza_filter, -999);