Diff

mod_smacks/mod_smacks.lua @ 3646:58047d6f2b89

mod_smacks: fix bug #1405 (prevent timer from running for already destroyed sessions)
author tmolitor <thilo@eightysoft.de>
date Sun, 11 Aug 2019 02:58:56 +0200
parent 3640:b2f32b3c6ec1
child 3841:b5d367798570
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Sat Aug 10 14:19:48 2019 +0200
+++ b/mod_smacks/mod_smacks.lua	Sun Aug 11 02:58:56 2019 +0200
@@ -5,7 +5,7 @@
 -- Copyright (C) 2012-2015 Kim Alvefur
 -- Copyright (C) 2012 Thijs Alkemade
 -- Copyright (C) 2014 Florian Zeitz
--- Copyright (C) 2016-2017 Thilo Molitor
+-- Copyright (C) 2016-2019 Thilo Molitor
 --
 -- This project is MIT/X11 licensed. Please see the
 -- COPYING file in the source package for more information.
@@ -116,7 +116,7 @@
 end
 
 local function delayed_ack_function(session)
-	-- fire event only if configured to do so and our session is not hibernated or destroyed
+	-- fire event only if configured to do so and our session is not already hibernated or destroyed
 	if delayed_ack_timeout > 0 and session.awaiting_ack
 	and not session.hibernating and not session.destroyed then
 		session.log("debug", "Firing event 'smacks-ack-delayed', queue = %d",
@@ -171,7 +171,8 @@
 			session.awaiting_ack = false;
 			session.awaiting_ack_timer = stoppable_timer(1e-06, function ()
 				-- session.log("debug", "*** SMACKS(3) ***: awaiting_ack=%s, hibernating=%s", tostring(session.awaiting_ack), tostring(session.hibernating));
-				if not session.awaiting_ack and not session.hibernating then
+				-- only request ack if needed and our session is not already hibernated or destroyed
+				if not session.awaiting_ack and not session.hibernating and not session.destroyed then
 					session.log("debug", "Sending <r> (inside timer, before send) from %s - #queue=%d", reason, #queue);
 					(session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks }))
 					session.awaiting_ack = true;