dovecot-2.1: mdbox: Don't leave extra records to dovecot.map.ind...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Nov 7 17:05:53 EET 2012
details: http://hg.dovecot.org/dovecot-2.1/rev/6c1b4b9f527c
changeset: 14798:6c1b4b9f527c
user: Timo Sirainen <tss at iki.fi>
date: Wed Nov 07 17:05:47 2012 +0200
description:
mdbox: Don't leave extra records to dovecot.map.index if mailbox index locking fails.
Fixes errors such as:
Corrupted dbox file /mdbox/storage/m.1 (around offset=2652): EOF reading msg header (got 0/30 bytes)
diffstat:
src/lib-storage/index/dbox-multi/mdbox-save.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diffs (37 lines):
diff -r bcd2d140ea10 -r 6c1b4b9f527c src/lib-storage/index/dbox-multi/mdbox-save.c
--- a/src/lib-storage/index/dbox-multi/mdbox-save.c Tue Nov 06 22:13:13 2012 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-save.c Wed Nov 07 17:05:47 2012 +0200
@@ -296,16 +296,6 @@
mdbox_transaction_save_rollback(_ctx);
return -1;
}
-
- /* assign map UIDs for newly saved messages. they're written to
- transaction log immediately within this function, but the map
- is left locked. */
- if (mdbox_map_append_assign_map_uids(ctx->append_ctx, &first_map_uid,
- &last_map_uid) < 0) {
- mdbox_transaction_save_rollback(_ctx);
- return -1;
- }
-
/* lock the mailbox after map to avoid deadlocks. if we've noticed
any corruption, deal with it later, otherwise we won't have
up-to-date atomic->sync_view */
@@ -318,6 +308,16 @@
return -1;
}
+ /* assign map UIDs for newly saved messages after we've successfully
+ acquired all the locks. the transaction is now very unlikely to
+ fail. the UIDs are written to the transaction log immediately within
+ this function, but the map is left locked. */
+ if (mdbox_map_append_assign_map_uids(ctx->append_ctx, &first_map_uid,
+ &last_map_uid) < 0) {
+ mdbox_transaction_save_rollback(_ctx);
+ return -1;
+ }
+
/* assign UIDs for new messages */
hdr = mail_index_get_header(ctx->sync_ctx->sync_view);
mail_index_append_finish_uids(ctx->ctx.trans, hdr->next_uid,
More information about the dovecot-cvs
mailing list