From: Timo Sirainen Date: Fri, 20 Apr 2012 16:08:25 +0000 (+0300) Subject: director: Forward DIRECTOR commands to other connected directors. X-Git-Tag: 2.1.5~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9b08dc8d71bd655e5648daf8a09ff4b728cae81;p=thirdparty%2Fdovecot%2Fcore.git 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. --- diff --git a/src/director/director-connection.c b/src/director/director-connection.c index 52f03bee0c..8c64747143 100644 --- a/src/director/director-connection.c +++ b/src/director/director-connection.c @@ -562,24 +562,37 @@ static bool director_cmd_director(struct director_connection *conn, 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; + } + 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)); } - - /* 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)); return TRUE; }