]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Always update index map while committing a transaction.
authorTimo Sirainen <tss@iki.fi>
Wed, 6 Oct 2010 17:20:26 +0000 (18:20 +0100)
committerTimo Sirainen <tss@iki.fi>
Wed, 6 Oct 2010 17:20:26 +0000 (18:20 +0100)
The previous code was doing this only in some situations, which was probably
enough, except maybe in some special cases. The log file was also read until
EOF always anyway, so the only thing this was saving was some CPU. With the
new behavior the committing stage should be more reliable, and also makes it
easier to do changes without accidentally breaking it.

src/lib-index/mail-index-transaction-finish.c
src/lib-index/mail-index-transaction-private.h
src/lib-index/mail-index-transaction.c

index 0d6ab1e2d9c54d386b0df56355e40ebcfdd800bd..6af99568f7a111c17bd4b2ace98323c6bc44cb8b 100644 (file)
@@ -316,7 +316,7 @@ mail_index_transaction_convert_to_uids(struct mail_index_transaction *t)
        mail_index_convert_to_uid_ranges(t, &t->keyword_resets);
 }
 
-int mail_index_transaction_finish(struct mail_index_transaction *t)
+void mail_index_transaction_finish(struct mail_index_transaction *t)
 {
        if (array_is_created(&t->appends)) {
                mail_index_update_day_headers(t);
@@ -324,11 +324,6 @@ int mail_index_transaction_finish(struct mail_index_transaction *t)
        }
        mail_index_transaction_finish_flag_updates(t);
 
-       if (array_is_created(&t->ext_reset_atomic) || t->max_modseq != 0) {
-               if (mail_index_map(t->view->index,
-                                  MAIL_INDEX_SYNC_HANDLER_HEAD) <= 0)
-                       return -1;
-       }
        if (array_is_created(&t->ext_reset_atomic))
                transaction_update_atomic_reset_ids(t);
        if (t->max_modseq != 0)
@@ -340,5 +335,4 @@ int mail_index_transaction_finish(struct mail_index_transaction *t)
        /* and kind of ugly way to update highest modseq */
        if (t->min_highest_modseq != 0)
                mail_index_update_modseq(t, 0, t->min_highest_modseq);
-       return 0;
 }
index c8a89e5583a3e010661cae46fc43fe1526de94de..1004dfcbcd35339814ddd80b1d9add409c317664 100644 (file)
@@ -126,7 +126,7 @@ bool mail_index_cancel_flag_updates(struct mail_index_transaction *t,
 bool mail_index_cancel_keyword_updates(struct mail_index_transaction *t,
                                       uint32_t seq);
 
-int mail_index_transaction_finish(struct mail_index_transaction *t);
+void mail_index_transaction_finish(struct mail_index_transaction *t);
 void mail_index_transaction_export(struct mail_index_transaction *t,
                                   struct mail_transaction_log_append_ctx *append_ctx);
 int mail_transaction_expunge_guid_cmp(const struct mail_transaction_expunge_guid *e1,
index 81fe7a7f856dc526a0086b2ddef2c8c93dc6a7c3..95ed239f1f79aa1a4944190518cdfd507e9c05fc 100644 (file)
@@ -109,12 +109,10 @@ mail_transaction_log_file_refresh(struct mail_index_transaction *t,
        }
        file = t->view->index->log->head;
 
-       if (!t->view->index->log_sync_locked) {
-               /* update sync_offset */
-               if (mail_transaction_log_file_map(file, file->sync_offset,
-                                                 (uoff_t)-1) <= 0)
-                       return -1;
-       }
+       /* make sure we have everything mapped */
+       if (mail_index_map(t->view->index, MAIL_INDEX_SYNC_HANDLER_HEAD) <= 0)
+               return -1;
+
        i_assert(file->sync_offset >= file->buffer_offset);
        ctx->new_highest_modseq = file->sync_highest_modseq;
        return 1;
@@ -135,9 +133,8 @@ mail_index_transaction_commit_real(struct mail_index_transaction *t,
                return -1;
        ret = mail_transaction_log_file_refresh(t, ctx);
        if (ret > 0) {
-               ret = mail_index_transaction_finish(t);
-               if (ret == 0)
-                       mail_index_transaction_export(t, ctx);
+               mail_index_transaction_finish(t);
+               mail_index_transaction_export(t, ctx);
        }
 
        mail_transaction_log_get_head(log, &log_seq1, &log_offset1);