In preparation for the following changes.
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;
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;
}
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',
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) {
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;
}
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');
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);
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);
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,