changeset 18661:f43adca71e15

director: Improved debug logging about connecting to another director.
author Timo Sirainen <tss@iki.fi>
date Wed, 13 May 2015 04:07:46 +0300
parents e899171adc14
children 27baf04f2b18
files src/director/director.c
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/director/director.c	Wed May 13 00:33:18 2015 +0300
+++ b/src/director/director.c	Wed May 13 04:07:46 2015 +0300
@@ -109,8 +109,22 @@
 	if (director_has_outgoing_connection(dir, host))
 		return 0;
 
-	dir_debug("Connecting to %s:%u",
-		  net_ip2addr(&host->ip), host->port);
+	if (director_debug) {
+		string_t *str = t_str_new(128);
+
+		str_printfa(str, "Connecting to %s:%u (as %s",
+			    net_ip2addr(&host->ip), host->port,
+			    net_ip2addr(&dir->self_ip));
+		if (host->last_network_failure > 0) {
+			str_printfa(str, ", last network failure %ds ago",
+				    (int)(ioloop_time - host->last_network_failure));
+		}
+		if (host->last_protocol_failure > 0) {
+			str_printfa(str, ", last protocol failure %ds ago",
+				    (int)(ioloop_time - host->last_protocol_failure));
+		}
+		dir_debug("%s", str_c(str));
+	}
 	port = dir->test_port != 0 ? dir->test_port : host->port;
 	fd = net_connect_ip(&host->ip, port, &dir->self_ip);
 	if (fd == -1) {