Mercurial > dovecot > core-2.2
changeset 21326:2534aa23ae2d
imapc: Don't retry a failed reconnection before 10 secs have passed
This mainly avoids a lot of unnecessary connect attempts within a short
time period, for example if the caller attempts to perform some work for
all the mailboxes.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 15 Dec 2016 17:36:39 +0200 |
parents | 915b968cae77 |
children | 71d1be9f77bd |
files | src/lib-imap-client/imapc-connection.c |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-imap-client/imapc-connection.c Thu Dec 15 17:31:18 2016 +0200 +++ b/src/lib-imap-client/imapc-connection.c Thu Dec 15 17:36:39 2016 +0200 @@ -24,6 +24,7 @@ #define IMAPC_COMMAND_STATE_AUTHENTICATE_CONTINUE 10000 #define IMAPC_MAX_INLINE_LITERAL_SIZE (1024*32) +#define IMAPC_RECONNECT_MIN_RETRY_SECS 10 enum imapc_input_state { IMAPC_INPUT_STATE_NONE = 0, @@ -95,6 +96,7 @@ enum imapc_input_state input_state; unsigned int cur_tag; uint32_t cur_num; + time_t last_connect; struct imapc_client_mailbox *selecting_box, *selected_box; enum imapc_connection_state state; @@ -1728,6 +1730,13 @@ imapc_connection_input_reset(conn); + if (!conn->reconnect_ok && + conn->last_connect + IMAPC_RECONNECT_MIN_RETRY_SECS >= ioloop_time) { + imapc_connection_set_disconnected(conn); + return; + } + conn->last_connect = ioloop_time; + if (conn->client->set.debug) i_debug("imapc(%s): Looking up IP address", conn->name);