dovecot-2.2: director: Code cleanup - access host->tag via mail_...

dovecot at dovecot.org dovecot at dovecot.org
Tue Nov 24 09:16:07 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/7e47f561ad49
changeset: 19408:7e47f561ad49
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Nov 23 19:41:38 2015 +0200
description:
director: Code cleanup - access host->tag via mail_host_get_tag()
In preparation for the following changes.

diffstat:

 src/director/director-connection.c |  12 +++++++-----
 src/director/director.c            |   7 ++++---
 src/director/doveadm-connection.c  |   5 +++--
 src/director/mail-host.c           |   5 +++++
 src/director/mail-host.h           |   1 +
 5 files changed, 20 insertions(+), 10 deletions(-)

diffs (116 lines):

diff -r 39cfca637d60 -r 7e47f561ad49 src/director/director-connection.c
--- a/src/director/director-connection.c	Mon Nov 23 19:38:31 2015 +0200
+++ b/src/director/director-connection.c	Mon Nov 23 19:41:38 2015 +0200
@@ -863,7 +863,7 @@
 	struct director_host *src_host = conn->host;
 	struct mail_host *host;
 	struct ip_addr ip;
-	const char *tag = "", *hostname = NULL;
+	const char *tag = "", *host_tag, *hostname = NULL;
 	unsigned int arg_count, vhost_count;
 	bool update, down = FALSE;
 	time_t last_updown_change = 0;
@@ -904,10 +904,11 @@
 			host->down != down ||
 			host->last_updown_change != last_updown_change;
 
-		if (strcmp(tag, host->tag) != 0) {
+		host_tag = mail_host_get_tag(host);
+		if (strcmp(tag, host_tag) != 0) {
 			i_error("director(%s): Host %s changed tag from '%s' to '%s'",
 				conn->name, net_ip2addr(&host->ip),
-				host->tag, tag);
+				host_tag, tag);
 			mail_host_set_tag(host, tag);
 			update = TRUE;
 		}
@@ -1694,12 +1695,13 @@
 	str_printfa(str, "HOST-HAND-START\t%u\n", conn->dir->ring_handshaked);
 	array_foreach(mail_hosts_get(conn->dir->mail_hosts), hostp) {
 		struct mail_host *host = *hostp;
+		const char *host_tag = mail_host_get_tag(host);
 
 		str_printfa(str, "HOST\t%s\t%u",
 			    net_ip2addr(&host->ip), host->vhost_count);
-		if (host->tag[0] != '\0' || send_updowns) {
+		if (host_tag[0] != '\0' || send_updowns) {
 			str_append_c(str, '\t');
-			str_append_tabescaped(str, host->tag);
+			str_append_tabescaped(str, host_tag);
 		}
 		if (send_updowns) {
 			str_printfa(str, "\t%c%ld\t", host->down ? 'D' : 'U',
diff -r 39cfca637d60 -r 7e47f561ad49 src/director/director.c
--- a/src/director/director.c	Mon Nov 23 19:38:31 2015 +0200
+++ b/src/director/director.c	Mon Nov 23 19:41:38 2015 +0200
@@ -523,6 +523,7 @@
 		   struct director_host *orig_src,
 		   struct mail_host *host)
 {
+	const char *host_tag = mail_host_get_tag(host);
 	string_t *str;
 
 	if (orig_src == NULL) {
@@ -537,11 +538,11 @@
 		    net_ip2addr(&host->ip), host->vhost_count);
 	if (dir->ring_min_version >= DIRECTOR_VERSION_TAGS) {
 		str_append_c(str, '\t');
-		str_append_tabescaped(str, host->tag);
-	} else if (host->tag[0] != '\0' &&
+		str_append_tabescaped(str, host_tag);
+	} else if (host_tag[0] != '\0' &&
 		   dir->ring_min_version < DIRECTOR_VERSION_TAGS) {
 		i_error("Ring has directors that don't support tags - removing host %s with tag '%s'",
-			net_ip2addr(&host->ip), host->tag);
+			net_ip2addr(&host->ip), host_tag);
 		director_remove_host(dir, NULL, NULL, host);
 		return;
 	}
diff -r 39cfca637d60 -r 7e47f561ad49 src/director/doveadm-connection.c
--- a/src/director/doveadm-connection.c	Mon Nov 23 19:38:31 2015 +0200
+++ b/src/director/doveadm-connection.c	Mon Nov 23 19:41:38 2015 +0200
@@ -50,7 +50,7 @@
 		str_printfa(str, "%s\t%u\t%u\t",
 			    net_ip2addr(&(*hostp)->ip), (*hostp)->vhost_count,
 			    (*hostp)->user_count);
-		str_append_tabescaped(str, (*hostp)->tag);
+		str_append_tabescaped(str, mail_host_get_tag(*hostp));
 		str_printfa(str, "\t%c\t%ld", (*hostp)->down ? 'D' : 'U',
 			    (long)(*hostp)->last_updown_change);
 		str_append_c(str, '\n');
@@ -422,7 +422,8 @@
 		if (user->host != host)
 			continue;
 		new_host = mail_host_get_by_hash(dir->mail_hosts,
-						 user->username_hash, host->tag);
+						 user->username_hash,
+						 mail_host_get_tag(host));
 		if (new_host != host) T_BEGIN {
 			director_move_user(dir, src, NULL,
 					   user->username_hash, new_host);
diff -r 39cfca637d60 -r 7e47f561ad49 src/director/mail-host.c
--- a/src/director/mail-host.c	Mon Nov 23 19:38:31 2015 +0200
+++ b/src/director/mail-host.c	Mon Nov 23 19:41:38 2015 +0200
@@ -298,6 +298,11 @@
 	return ret;
 }
 
+const char *mail_host_get_tag(struct mail_host *host)
+{
+	return host->tag;
+}
+
 void mail_host_set_tag(struct mail_host *host, const char *tag)
 {
 	i_assert(tag != NULL);
diff -r 39cfca637d60 -r 7e47f561ad49 src/director/mail-host.h
--- a/src/director/mail-host.h	Mon Nov 23 19:38:31 2015 +0200
+++ b/src/director/mail-host.h	Mon Nov 23 19:41:38 2015 +0200
@@ -38,6 +38,7 @@
 
 int mail_hosts_parse_and_add(struct mail_host_list *list,
 			     const char *hosts_string);
+const char *mail_host_get_tag(struct mail_host *host);
 void mail_host_set_tag(struct mail_host *host, const char *tag);
 void mail_host_set_down(struct mail_host *host, bool down, time_t timestamp);
 void mail_host_set_vhost_count(struct mail_host *host,


More information about the dovecot-cvs mailing list