From: Timo Sirainen Date: Thu, 20 May 2010 08:43:19 +0000 (+0200) Subject: director: Fixes to connecting to remote director. X-Git-Tag: 2.0.beta6~181 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8e1ecc6542da1e14c14e2e59d39dbccdbf68e2b5;p=thirdparty%2Fdovecot%2Fcore.git director: Fixes to connecting to remote director. --HG-- branch : HEAD --- diff --git a/src/director/director-connection.c b/src/director/director-connection.c index 4ed8c8d265..61f912c6cb 100644 --- a/src/director/director-connection.c +++ b/src/director/director-connection.c @@ -139,10 +139,11 @@ static bool director_cmd_me(struct director_connection *conn, if (dir->left->host != dir->right->host) director_connection_send(dir->right, connect_str); else { - /* there are only two directors */ + /* there are only two directors, and we already have + a connection to this server. */ } } else { - /* looks like we're the right side. */ + /* there are only two directors. connect to the other one. */ (void)director_connect_host(dir, host); } return TRUE; diff --git a/src/director/director.c b/src/director/director.c index 01164075e8..ca0a6f22de 100644 --- a/src/director/director.c +++ b/src/director/director.c @@ -80,11 +80,6 @@ int director_connect_host(struct director *dir, struct director_host *host) i_assert(dir->right == NULL); - if (host->last_failed + DIRECTOR_RECONNECT_RETRY_SECS > ioloop_time) { - /* failed recently, don't try retrying here */ - return -1; - } - fd = net_connect_ip(&host->ip, host->port, &dir->self_ip); if (fd == -1) { host->last_failed = ioloop_time; @@ -110,6 +105,12 @@ void director_connect(struct director *dir) for (i = 1; i < count; i++) { unsigned int idx = (self_idx + i) % count; + if (hosts[idx]->last_failed + + DIRECTOR_RECONNECT_RETRY_SECS > ioloop_time) { + /* failed recently, don't try retrying here */ + continue; + } + if (director_connect_host(dir, hosts[idx]) == 0) break; }