From 3a3d9c6c2c425998e2edf5d1d9f910f25ee39af4 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 2 Apr 2023 10:37:44 +0200 Subject: mod_smacks: Fix stray watchdog closing sessions Unsure exactly how this happens, but sometimes a watchdog appears to close a session that isn't hibernating, or hasn't hibernating long enough. --- plugins/mod_smacks.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'plugins/mod_smacks.lua') diff --git a/plugins/mod_smacks.lua b/plugins/mod_smacks.lua index a4ff0444..756e2d9a 100644 --- a/plugins/mod_smacks.lua +++ b/plugins/mod_smacks.lua @@ -474,7 +474,12 @@ module:hook("pre-resource-unbind", function (event) if session.hibernating then return end session.hibernating = os_time(); - session.hibernating_watchdog = watchdog.new(resume_timeout, function() + session.hibernating_watchdog = watchdog.new(resume_timeout, function(this_dog) + if this_dog ~= session.hibernating_watchdog then + -- This really shouldn't happen? + session.log("debug", "Releasing a stray watchdog"); + return + end session.log("debug", "mod_smacks hibernation timeout reached..."); if session.destroyed then session.log("debug", "The session has already been destroyed"); -- cgit v1.2.3 From d840f273201196765e75c97370efa4cd2ed8d75d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 2 Apr 2023 10:40:48 +0200 Subject: mod_smacks: Replace existing watchdog when starting hibernation There shouldn't be one here but if there is, for some reason, it's better to close it than have it around to wake up and possibly try to destroy the session. --- plugins/mod_smacks.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugins/mod_smacks.lua') diff --git a/plugins/mod_smacks.lua b/plugins/mod_smacks.lua index 756e2d9a..e0a7bbfb 100644 --- a/plugins/mod_smacks.lua +++ b/plugins/mod_smacks.lua @@ -474,6 +474,10 @@ module:hook("pre-resource-unbind", function (event) if session.hibernating then return end session.hibernating = os_time(); + if session.hibernating_watchdog then + session.log("debug", "Session already has a sleeping watchdog, replacing it"); + session.hibernating_watchdog:cancel(); + end session.hibernating_watchdog = watchdog.new(resume_timeout, function(this_dog) if this_dog ~= session.hibernating_watchdog then -- This really shouldn't happen? -- cgit v1.2.3