director.c revision 3404b66f3fda78955be9b6891ce5f5d6e13ef97a
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen/* Copyright (c) 2010-2016 Dovecot authors, see the included COPYING file */
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen#define DIRECTOR_RECONNECT_TIMEOUT_MSECS (30*1000)
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen#define DIRECTOR_USER_MOVE_TIMEOUT_MSECS (30*1000)
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen#define DIRECTOR_QUICK_RECONNECT_TIMEOUT_MSECS 1000
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen#define DIRECTOR_DELAYED_DIR_REMOVE_MSECS (1000*30)
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainenconst char *user_kill_state_names[USER_KILL_STATE_DELAY+1] = {
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen "notify-received",
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen "waiting-for-notify",
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen "waiting-for-everyone",
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainenstatic struct log_throttle *user_move_throttle;
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainenstatic struct log_throttle *user_kill_fail_throttle;
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainenstatic const struct log_throttle_settings director_log_throttle_settings = {
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainendirector_user_kill_finish_delayed(struct director *dir, struct user *user,
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainenstatic bool director_is_self_ip_set(struct director *dir)
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen if (net_ip_compare(&dir->self_ip, &net_ip4_any))
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen if (net_ip_compare(&dir->self_ip, &net_ip6_any))
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainenstatic void director_find_self_ip(struct director *dir)
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen unsigned int i, count;
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen for (i = 0; i < count; i++) {
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen i_fatal("director_servers doesn't list ourself");
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen dir->self_host = director_host_lookup(dir, &dir->self_ip,
9c675f5e259c19f9fdc40808439479131b32421eTimo Sirainen i_fatal("director_servers doesn't list ourself (%s:%u)",
9c675f5e259c19f9fdc40808439479131b32421eTimo Sirainenstatic unsigned int director_find_self_idx(struct director *dir)
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen unsigned int i, count;
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen for (i = 0; i < count; i++) {
9c675f5e259c19f9fdc40808439479131b32421eTimo Sirainendirector_has_outgoing_connection(struct director *dir,
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen if (director_connection_get_host(*connp) == host &&
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainenint director_connect_host(struct director *dir, struct director_host *host)
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen if (director_has_outgoing_connection(dir, host))
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen str_printfa(str, "Connecting to %s:%u (as %s",
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen str_printfa(str, ", last network failure %ds ago",
e9068f1c3326de0265d0ef542a0d7723f5f01bc8Timo Sirainen (int)(ioloop_time - host->last_network_failure));
static struct director_host *
return NULL;
for (i = 0; i < count; i++) {
return host;
return NULL;
return FALSE;
return TRUE;
if (minor_version > 0 &&
return TRUE;
return FALSE;
const char *cmd;
unsigned int i, count;
for (i = 0; i < count; ) {
unsigned int i, count;
const char *cmd;
for (i = 0; i < count; ) {
const char *cmd;
i_unreached();
if (result == 0) {
char *data;
data);
const char *error;
error);
bool skip_delay)
if (skip_delay) {
} else if (self ||
switch (state) {
case IPC_CLIENT_CMD_STATE_OK:
const char *cmd;
unsigned int username_hash,
const char *cmd;
unsigned int username_hash)
case USER_KILL_STATE_KILLING:
case USER_KILL_STATE_NONE:
case USER_KILL_STATE_FLUSHING:
case USER_KILL_STATE_DELAY:
unsigned int username_hash)
const char *cmd)
struct director *
return dir;
if (!director_debug)
T_BEGIN {
} T_END;
void directors_init(void)
void directors_deinit(void)