]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap-client: Avoid infinite reconnection loops when retrying command fails
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 18 May 2017 14:36:27 +0000 (17:36 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 19 May 2017 10:56:25 +0000 (13:56 +0300)
reconnect_command_count wasn't calculated correctly, because the SELECT and
potentially other following sync commands weren't included in it.

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

index 54dadbdff897a72b1e6dd26e7760422d259c4d4a..03afe4f752a6a330c0c2c50db7838e3f24bc5469 100644 (file)
@@ -52,7 +52,9 @@ enum imapc_command_flags {
           finishes. */
        IMAPC_COMMAND_FLAG_RETRIABLE    = 0x04,
        /* This is the LOGOUT command. Use a small timeout for it. */
-       IMAPC_COMMAND_FLAG_LOGOUT       = 0x08
+       IMAPC_COMMAND_FLAG_LOGOUT       = 0x08,
+       /* Command is being resent after a reconnection. */
+       IMAPC_COMMAND_FLAG_RECONNECTED  = 0x10
 };
 
 enum imapc_client_ssl_mode {
index 6eaf1ab93cf5693243b698c455d91cbbd0db67ec..7e71b333c1af3eb4d8ebfbbeba4dd2fb5a57addf 100644 (file)
@@ -300,6 +300,7 @@ imapc_connection_abort_commands_array(ARRAY_TYPE(imapc_command) *cmd_array,
                         (cmd->flags & IMAPC_COMMAND_FLAG_RETRIABLE) != 0) {
                        cmd->send_pos = 0;
                        cmd->wait_for_literal = 0;
+                       cmd->flags |= IMAPC_COMMAND_FLAG_RECONNECTED;
                        i++;
                } else {
                        array_delete(cmd_array, i, 1);
@@ -1435,7 +1436,7 @@ static int imapc_connection_input_tagged(struct imapc_connection *conn)
        }
 
        if (conn->reconnect_command_count > 0 &&
-           (cmd->flags & IMAPC_COMMAND_FLAG_PRELOGIN) == 0) {
+           (cmd->flags & IMAPC_COMMAND_FLAG_RECONNECTED) != 0) {
                if (--conn->reconnect_command_count == 0) {
                        /* we've received replies for all the commands started
                           before reconnection. if we get disconnected now, we