changeset 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 063abaab666f
children 58d61459cdb1
files mod_smacks/mod_smacks.lua
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
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();