Changeset

12879:09a53ed8f4d5 0.12

sessionmanager: Improve logging around session destruction
author Matthew Wild <mwild1@gmail.com>
date Thu, 09 Feb 2023 15:09:03 +0000 (22 months ago)
parents 12878:0d8bf401fa73
children 12880:b56a2731bf00 12881:91baddaeea84
files core/sessionmanager.lua
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/core/sessionmanager.lua	Thu Jan 19 21:40:09 2023 +0100
+++ b/core/sessionmanager.lua	Thu Feb 09 15:09:03 2023 +0000
@@ -94,9 +94,6 @@
 
 local function destroy_session(session, err)
 	if session.destroyed then return; end
-	(session.log or log)("debug", "Destroying session for %s (%s@%s)%s",
-		session.full_jid or "(unknown)", session.username or "(unknown)",
-		session.host or "(unknown)", err and (": "..err) or "");
 
 	-- Remove session/resource from user's session list
 	if session.full_jid then
@@ -104,8 +101,14 @@
 
 		-- Allow plugins to prevent session destruction
 		if host_session.events.fire_event("pre-resource-unbind", {session=session, error=err}) then
+			(session.log or log)("debug", "Resource unbind prevented by module");
 			return;
 		end
+
+		(session.log or log)("debug", "Unbinding resource for %s (%s@%s)%s",
+			session.full_jid or "(unknown)", session.username or "(unknown)",
+			session.host or "(unknown)", err and (": "..err) or "");
+
 		session.destroyed = true; -- Past this point the session is DOOMED!
 
 		host_session.sessions[session.username].sessions[session.resource] = nil;
@@ -118,6 +121,10 @@
 		end
 
 		host_session.events.fire_event("resource-unbind", {session=session, error=err});
+	else
+		(session.log or log)("debug", "Destroying unbound session for <%s@%s>%s",
+			session.username or "(unknown)", session.host or "(unknown)",
+			err and (": "..err) or "");
 	end
 
 	retire_session(session);