changeset 14493:1856e9085f94

director: Forward DIRECTOR commands to other connected directors. They can use it to realize that the director was restarted and its sequences start from 1.
author Timo Sirainen <tss@iki.fi>
date Fri, 20 Apr 2012 19:08:25 +0300
parents f880cf0efa0a
children d27b743c9921
files src/director/director-connection.c
diffstat 1 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/director/director-connection.c	Fri Apr 20 19:05:38 2012 +0300
+++ b/src/director/director-connection.c	Fri Apr 20 19:08:25 2012 +0300
@@ -562,24 +562,37 @@
 	struct director_host *host;
 	struct ip_addr ip;
 	unsigned int port;
+	bool forward = FALSE;
 
 	if (!director_args_parse_ip_port(conn, args, &ip, &port))
 		return FALSE;
 
 	host = director_host_lookup(conn->dir, &ip, port);
 	if (host != NULL) {
+		if (host == conn->dir->self_host) {
+			/* ignore updates to ourself */
+			return TRUE;
+		}
+
 		/* already have this. just reset its last_network_failure
 		   timestamp, since it might be up now. */
 		host->last_network_failure = 0;
-		/* it also may have been restarted, so reset last_seq */
-		host->last_seq = 0;
-		return TRUE;
+		if (host->last_seq != 0) {
+			/* it also may have been restarted, reset last_seq */
+			host->last_seq = 0;
+			forward = TRUE;
+		}
+	} else {
+		/* save the director and forward it */
+		director_host_add(conn->dir, &ip, port);
+		forward = TRUE;
 	}
-
-	/* save the director and forward it */
-	director_host_add(conn->dir, &ip, port);
-	director_update_send(conn->dir, director_connection_get_host(conn),
-		t_strdup_printf("DIRECTOR\t%s\t%u\n", net_ip2addr(&ip), port));
+	if (forward) {
+		director_update_send(conn->dir,
+			director_connection_get_host(conn),
+			t_strdup_printf("DIRECTOR\t%s\t%u\n",
+					net_ip2addr(&ip), port));
+	}
 	return TRUE;
 }