# HG changeset patch # User tmolitor # Date 1486931048 -3600 # Node ID 5ca2470a77552d21c1a4690a3d1509beeb5c3481 # Parent d300ae5dba877a472a624887231eeb4aad909378# Parent a6486881fe4259eff6fbd49ce15b2f93b16209c6 merged upstream changes diff -r a6486881fe42 -r 5ca2470a7755 mod_smacks/mod_smacks.lua --- a/mod_smacks/mod_smacks.lua Sun Feb 12 17:05:44 2017 +0100 +++ b/mod_smacks/mod_smacks.lua Sun Feb 12 21:24:08 2017 +0100 @@ -43,10 +43,11 @@ local function delayed_ack_function(session) -- fire event only when configured to do so - if delayed_ack_timeout > 0 and session.awaiting_ack and not session.outgoing_stanza_queue == nil then + if delayed_ack_timeout > 0 and session.awaiting_ack and not (session.outgoing_stanza_queue == nil) then session.log("debug", "Firing event 'smacks-ack-delayed', queue = %d", #session.outgoing_stanza_queue); module:fire_event("smacks-ack-delayed", {origin = session, queue = session.outgoing_stanza_queue}); end + session.delayed_ack_timer = nil; end local function can_do_smacks(session, advertise_only) @@ -97,6 +98,14 @@ end end); end + -- Trigger "smacks-ack-delayed"-event if we added new (ackable) stanzas to the outgoing queue + -- 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 + session.log("debug", "Calling delayed_ack_function directly (still waiting for ack)"); + delayed_ack_function(session); + end end local function outgoing_stanza_filter(stanza, session) @@ -241,6 +250,7 @@ end if origin.delayed_ack_timer then origin.delayed_ack_timer:stop(); + origin.delayed_ack_timer = nil; end -- Remove handled stanzas from outgoing_stanza_queue log("debug", "ACK: h=%s, last=%s", stanza.attr.h or "", origin.last_acknowledged_stanza or ""); @@ -430,6 +440,7 @@ end if session.delayed_ack_timer then session.delayed_ack_timer:stop(); + session.delayed_ack_timer = nil; end return false; -- Kick the session end