Changeset

1006:9166d7a8c3c0

core.s2smanager: Logging improvements
author Matthew Wild <mwild1@gmail.com>
date Mon, 20 Apr 2009 22:13:09 +0100
parents 1005:0eed5db7758d
children 1007:c500d4cb7855
files core/s2smanager.lua
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/core/s2smanager.lua	Sat Apr 18 17:48:30 2009 +0100
+++ b/core/s2smanager.lua	Mon Apr 20 22:13:09 2009 +0100
@@ -105,7 +105,11 @@
 		local host_session = new_outgoing(from_host, to_host);
 		-- Store in buffer
 		host_session.sendq = { {tostring(data), st.reply(data)} };
-		if (not host_session.connecting) and (not host_session.conn) then destroy_session(host_session); end
+		log("debug", "stanza [%s] queued until connection complete", tostring(data.name));
+		if (not host_session.connecting) and (not host_session.conn) then
+			log("warn", "Connection to %s failed already, destroying session...", to_host);
+			destroy_session(host_session);
+		end
 	end
 end
 
@@ -146,6 +150,7 @@
 	local connect_host, connect_port = idna_to_ascii(to_host), 5269;
 	
 	if not err then -- This is our first attempt
+		log("debug", "First attempt to connect to %s, starting with SRV lookup...", to_host);
 		host_session.connecting = true;
 		local answer = 
 		adns.lookup(function (answer)
@@ -171,6 +176,7 @@
 			-- Try with SRV, or just the plain hostname if no SRV
 			return try_connect(host_session, connect_host, connect_port);
 		end, "_xmpp-server._tcp."..connect_host..".", "SRV");
+		log("debug", "DNS lookup for %s sent, waiting for response before we can connect", to_host);
 		return true; -- Attempt in progress
 	elseif host_session.srv_hosts and #host_session.srv_hosts > host_session.srv_choice then -- Not our first attempt, and we also have SRV
 		host_session.srv_choice = host_session.srv_choice + 1;
@@ -185,6 +191,7 @@
 	
 	if not (connect_host and connect_port) then
 		-- Likely we couldn't resolve DNS
+		log("warn", "Hmm, we're without a host (%s) and port (%s) to connect to for %s, giving up :(", tostring(connect_host), tostring(connect_port), tostring(to_host));
 		return false;
 	end
 	
@@ -267,6 +274,7 @@
 end
 
 function streamclosed(session)
+	(session.log or log)("debug", "</stream:stream>");
 	session.sends2s("</stream:stream>");
 	session.notopen = true;
 end