]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: mail_index_sync_next() didn't always return expunges sorted
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 21 Feb 2016 01:40:48 +0000 (03:40 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 21 Feb 2016 01:44:17 +0000 (03:44 +0200)
Maildir and mbox formats were using index_sync_changes_read(), which assumed that
they were sorted. So some of the intended expunges weren't actually always being
done. This mainly affected when expunges were being done simultaneously by multiple
processes or by pipelined commands. For example:

printf "a select inbox\nb uid move 2 Trash\nc uid move 1 Trash\nd logout\n" | ./imap

src/lib-index/mail-index-sync.c

index d0320dd0aa48a887132e75b7eb5d2b70e904828a..405aa4c4cf2cbb98a704b51388d425118ef2c08f 100644 (file)
@@ -206,6 +206,7 @@ mail_index_sync_read_and_sort(struct mail_index_sync_ctx *ctx)
        i_array_init(&ctx->sync_list, keyword_count + 2);
 
        if (array_is_created(&sync_trans->expunges)) {
+               mail_index_transaction_sort_expunges(sync_trans);
                synclist = array_append_space(&ctx->sync_list);
                synclist->array = (void *)&sync_trans->expunges;
        }