]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap-client: After reconnection send retried commands last
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 25 Dec 2017 16:49:15 +0000 (18:49 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Thu, 18 Jan 2018 10:05:11 +0000 (12:05 +0200)
Previously only SELECT was sent before others. This allows sending more
commands on reconnection before the retried commands.

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

index 66efaee31184ce66eb1a64c7d442b674d6918168..cfdec03101e7a6f42fe236511578c751da9f0f47 100644 (file)
@@ -2200,6 +2200,8 @@ static void imapc_connection_send_idle_done(struct imapc_connection *conn)
 static void imapc_connection_cmd_send(struct imapc_command *cmd)
 {
        struct imapc_connection *conn = cmd->conn;
+       struct imapc_command *const *cmds;
+       unsigned int i, count;
 
        imapc_connection_send_idle_done(conn);
 
@@ -2211,14 +2213,13 @@ static void imapc_connection_cmd_send(struct imapc_command *cmd)
                return;
        }
 
-       if ((cmd->flags & IMAPC_COMMAND_FLAG_SELECT) != 0 &&
-           conn->selected_box == NULL) {
-               /* reopening the mailbox. add it before other
-                  queued commands. */
-               array_insert(&conn->cmd_send_queue, 0, &cmd, 1);
-       } else {
-               array_append(&conn->cmd_send_queue, &cmd, 1);
+       /* add the command just before retried commands */
+       cmds = array_get(&conn->cmd_send_queue, &count);
+       for (i = count; i > 0; i--) {
+               if ((cmds[i-1]->flags & IMAPC_COMMAND_FLAG_RECONNECTED) == 0)
+                       break;
        }
+       array_insert(&conn->cmd_send_queue, i, &cmd, 1);
        imapc_command_send_more(conn);
 }