dovecot-2.2: lib-imap-client: If connect() fails immediately, lo...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Sep 1 13:26:13 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/e157d13efac9
changeset: 19055:e157d13efac9
user: Timo Sirainen <tss at iki.fi>
date: Tue Sep 01 16:25:11 2015 +0300
description:
lib-imap-client: If connect() fails immediately, log an error and retry the next IP.
Only if all IPs fail return a full failure. This is mainly intended to skip
IPv6 addresses when IPv6 connectivity doesn't work.
diffstat:
src/lib-imap-client/imapc-connection.c | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
diffs (37 lines):
diff -r c0e61e4f47ec -r e157d13efac9 src/lib-imap-client/imapc-connection.c
--- a/src/lib-imap-client/imapc-connection.c Tue Sep 01 00:11:37 2015 +0300
+++ b/src/lib-imap-client/imapc-connection.c Tue Sep 01 16:25:11 2015 +0300
@@ -1564,16 +1564,27 @@
static void imapc_connection_connect_next_ip(struct imapc_connection *conn)
{
const struct ip_addr *ip;
+ unsigned int i;
int fd;
i_assert(conn->client->set.max_idle_time > 0);
- conn->prev_connect_idx = (conn->prev_connect_idx+1) % conn->ips_count;
- ip = &conn->ips[conn->prev_connect_idx];
- fd = net_connect_ip(ip, conn->client->set.port, NULL);
- if (fd == -1) {
- imapc_connection_set_disconnected(conn);
- return;
+ for (i = 0;;) {
+ conn->prev_connect_idx = (conn->prev_connect_idx+1) % conn->ips_count;
+ ip = &conn->ips[conn->prev_connect_idx];
+ fd = net_connect_ip(ip, conn->client->set.port, NULL);
+ if (fd != -1)
+ break;
+
+ /* failed to connect to one of the IPs immediately
+ (e.g. IPv6 address without connectivity). try all IPs
+ before failing completely. */
+ i_error("net_connect_ip(%s:%u) failed: %m",
+ net_ip2addr(ip), conn->client->set.port);
+ if (++i == conn->ips_count) {
+ imapc_connection_set_disconnected(conn);
+ return;
+ }
}
conn->fd = fd;
conn->input = conn->raw_input = i_stream_create_fd(fd, (size_t)-1, FALSE);
More information about the dovecot-cvs
mailing list