Lines Matching defs:host
6 #include "director-host.h"
29 struct director_host *host;
33 host = i_new(struct director_host, 1);
34 host->dir = dir;
35 host->refcount = 1;
36 host->ip = *ip;
37 host->ip_str = i_strdup(net_ip2addr(&host->ip));
38 host->port = port;
39 host->name = i_strdup_printf("%s:%u", host->ip_str, port);
41 array_append(&dir->dir_hosts, &host, 1);
46 return host;
51 struct director_host *host = *_host;
53 i_assert(host->refcount == 1);
56 director_host_unref(host);
59 void director_host_ref(struct director_host *host)
61 i_assert(host->refcount > 0);
62 host->refcount++;
65 void director_host_unref(struct director_host *host)
70 i_assert(host->refcount > 0);
72 if (--host->refcount > 0)
75 hosts = array_get(&host->dir->dir_hosts, &count);
77 if (hosts[i] == host) {
78 array_delete(&host->dir->dir_hosts, i, 1);
82 i_free(host->name);
83 i_free(host->ip_str);
84 i_free(host);
87 void director_host_restarted(struct director_host *host)
89 host->last_seq = 0;
90 host->last_sync_seq = 0;
91 host->last_sync_seq_counter = 0;
92 host->last_sync_timestamp = 0;
99 struct director_host *host;
101 host = director_host_lookup(dir, ip, port);
102 if (host == NULL)
103 host = director_host_add(dir, ip, port);
104 return host;
154 static void director_host_add_string(struct director *dir, const char *host)
160 if (net_str2hostport(host, dir->self_port, &host, &port) < 0)
161 i_fatal("Invalid director host:port in '%s'", host);
163 if (net_gethostbyname(host, &ips, &ips_count) < 0)
164 i_fatal("Unknown director host: %s", host);