Changeset

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
parents 3645:413ea67597d2
children 3647:a0ca5d0a49ba
files mod_smacks/mod_smacks.lua
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
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;