diff mod_smacks/mod_smacks.lua @ 3218:67f1d1f22625

mod_smacks: Improve logging on resume so session changes are more easily tracked
author Matthew Wild <mwild1@gmail.com>
date Wed, 08 Aug 2018 12:49:02 +0100
parents 14b6ad2b773f
children 9b6206f23151
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Tue Aug 07 21:11:37 2018 +0100
+++ b/mod_smacks/mod_smacks.lua	Wed Aug 08 12:49:02 2018 +0100
@@ -467,6 +467,10 @@
 module:hook("s2sout-destroyed", handle_s2s_destroyed);
 module:hook("s2sin-destroyed", handle_s2s_destroyed);
 
+local function get_session_id(session)
+	return session.id or (tostring(session):match("[a-f0-9]+$"));
+end
+
 function handle_resume(session, stanza, xmlns_sm)
 	if session.full_jid then
 		session.log("warn", "Tried to resume after resource binding");
@@ -494,10 +498,10 @@
 		end;
 	elseif session.username == original_session.username
 	and session.host == original_session.host then
-		session.log("debug", "mod_smacks resuming existing session...");
+		session.log("debug", "mod_smacks resuming existing session %s...", get_session_id(original_session));
 		-- TODO: All this should move to sessionmanager (e.g. session:replace(new_session))
 		if original_session.conn then
-			session.log("debug", "mod_smacks closing an old connection for this session");
+			original_session.log("debug", "mod_smacks closing an old connection for this session");
 			local conn = original_session.conn;
 			c2s_sessions[conn] = nil;
 			conn:close();