changeset 12934:2b7af3a16521

director: Reset hosts' last_failed timestamps when they're suspected to be working again. This should fix some problems during director removals and additions.
author Timo Sirainen <tss@iki.fi>
date Fri, 08 Apr 2011 19:35:27 +0300
parents e2b747f88e54
children e9139f74c451
files src/director/director-connection.c src/director/director.c
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/director/director-connection.c	Fri Apr 08 17:27:52 2011 +0300
+++ b/src/director/director-connection.c	Fri Apr 08 19:35:27 2011 +0300
@@ -110,6 +110,9 @@
 		return FALSE;
 	}
 	host = director_host_get(dir, &ip, port);
+	/* the host is up now, make sure we can connect to it immediately
+	   if needed */
+	host->last_failed = 0;
 	conn->me_received = TRUE;
 
 	if (!conn->in)
@@ -286,7 +289,9 @@
 
 	host = director_host_lookup(conn->dir, &ip, port);
 	if (host != NULL) {
-		/* already have this, skip */
+		/* already have this. just reset its last_failed timestamp,
+		   since it might be up now. */
+		host->last_failed = 0;
 		return TRUE;
 	}
 
@@ -474,6 +479,7 @@
 	if (dir->debug)
 		i_debug("Handshaked to %s", conn->host->name);
 
+	conn->host->last_failed = 0;
 	conn->handshake_received = TRUE;
 	if (conn->in) {
 		/* handshaked to left side. tell it we've received the
@@ -548,6 +554,9 @@
 
 		conn->dir->right = NULL;
 		host = director_host_get(conn->dir, &ip, port);
+		/* reset failure timestamp so we'll actually try to
+		   connect there. */
+		host->last_failed = 0;
 		(void)director_connect_host(conn->dir, host);
 		return FALSE;
 	}
--- a/src/director/director.c	Fri Apr 08 17:27:52 2011 +0300
+++ b/src/director/director.c	Fri Apr 08 19:35:27 2011 +0300
@@ -94,6 +94,9 @@
 		i_error("connect(%s) failed: %m", host->name);
 		return -1;
 	}
+	/* Reset timestamp so that director_connect() won't skip this host
+	   while we're still trying to connect to it */
+	host->last_failed = 0;
 
 	director_connection_init_out(dir, fd, host);
 	return 0;