]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Don't retry a failed reconnection before 10 secs have passed
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 15 Dec 2016 15:36:39 +0000 (17:36 +0200)
committerGitLab <gitlab@git.dovecot.net>
Sat, 17 Dec 2016 09:07:07 +0000 (11:07 +0200)
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.

src/lib-imap-client/imapc-connection.c

index d52d87784796dc4e860a1c7de0a120a4fcc37c89..030496ed833581f86d54babb37098a5a450a3f65 100644 (file)
@@ -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 @@ struct imapc_connection {
        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;
@@ -1726,6 +1728,13 @@ void imapc_connection_connect(struct imapc_connection *conn,
 
        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);