[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-save.c,
1.41, 1.42 maildir-storage.h, 1.29, 1.30 maildir-transaction.c,
1.4, 1.5
cras at dovecot.org
cras at dovecot.org
Sun Oct 17 17:35:04 EEST 2004
Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv14117/maildir
Modified Files:
maildir-save.c maildir-storage.h maildir-transaction.c
Log Message:
Unlock uidlist file only after appends are written to transaction log.
Index: maildir-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-save.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- maildir-save.c 2 Sep 2004 16:53:36 -0000 1.41
+++ maildir-save.c 17 Oct 2004 14:35:01 -0000 1.42
@@ -26,6 +26,7 @@
struct index_mailbox *ibox;
struct mail_index_transaction *trans;
+ struct maildir_uidlist_sync_ctx *sync_ctx;
struct index_mail mail;
const char *tmpdir, *newdir, *curdir;
@@ -305,9 +306,8 @@
maildir_transaction_save_rollback(ctx);
}
-int maildir_transaction_save_commit(struct maildir_save_context *ctx)
+int maildir_transaction_save_commit_pre(struct maildir_save_context *ctx)
{
- struct maildir_uidlist_sync_ctx *sync_ctx;
struct maildir_filename *mf;
uint32_t first_uid, last_uid;
enum maildir_uidlist_rec_flag flags;
@@ -335,27 +335,28 @@
MAILDIR_UIDLIST_REC_FLAG_RECENT;
/* move them into new/ */
- sync_ctx = maildir_uidlist_sync_init(ctx->ibox->uidlist, TRUE);
+ ctx->sync_ctx = maildir_uidlist_sync_init(ctx->ibox->uidlist, TRUE);
for (mf = ctx->files; mf != NULL; mf = mf->next) {
fname = mf->dest != NULL ? mf->dest : mf->basename;
if (maildir_file_move(ctx, mf->basename, mf->dest) < 0 ||
- maildir_uidlist_sync_next(sync_ctx, fname, flags) < 0) {
- (void)maildir_uidlist_sync_deinit(sync_ctx);
+ maildir_uidlist_sync_next(ctx->sync_ctx,
+ fname, flags) < 0) {
+ (void)maildir_uidlist_sync_deinit(ctx->sync_ctx);
maildir_save_commit_abort(ctx, mf);
return -1;
}
}
+ return ret;
- if (maildir_uidlist_sync_deinit(sync_ctx) < 0) {
- maildir_save_commit_abort(ctx, NULL);
- return -1;
- }
+}
- i_assert(maildir_uidlist_get_next_uid(ctx->ibox->uidlist) == last_uid);
+void maildir_transaction_save_commit_post(struct maildir_save_context *ctx)
+{
+ /* can't do anything anymore if we fail */
+ (void)maildir_uidlist_sync_deinit(ctx->sync_ctx);
index_mail_deinit(&ctx->mail);
pool_unref(ctx->pool);
- return ret;
}
void maildir_transaction_save_rollback(struct maildir_save_context *ctx)
Index: maildir-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- maildir-storage.h 2 Sep 2004 16:53:36 -0000 1.29
+++ maildir-storage.h 17 Oct 2004 14:35:01 -0000 1.30
@@ -60,7 +60,8 @@
int maildir_save_finish(struct mail_save_context *ctx, struct mail **mail_r);
void maildir_save_cancel(struct mail_save_context *ctx);
-int maildir_transaction_save_commit(struct maildir_save_context *ctx);
+int maildir_transaction_save_commit_pre(struct maildir_save_context *ctx);
+void maildir_transaction_save_commit_post(struct maildir_save_context *ctx);
void maildir_transaction_save_rollback(struct maildir_save_context *ctx);
int maildir_copy(struct mailbox_transaction_context *t, struct mail *mail,
Index: maildir-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-transaction.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- maildir-transaction.c 29 Aug 2004 07:52:02 -0000 1.4
+++ maildir-transaction.c 17 Oct 2004 14:35:01 -0000 1.5
@@ -23,8 +23,10 @@
int ret = 0;
if (t->save_ctx != NULL) {
- if (maildir_transaction_save_commit(t->save_ctx) < 0)
+ if (maildir_transaction_save_commit_pre(t->save_ctx) < 0) {
+ t->save_ctx = NULL;
ret = -1;
+ }
}
if (t->copy_ctx != NULL) {
if (maildir_transaction_copy_commit(t->copy_ctx) < 0)
@@ -34,6 +36,12 @@
if (index_transaction_commit(_t) < 0)
return -1;
+ if (t->save_ctx != NULL) {
+ /* unlock uidlist file after writing to transaction log,
+ to make sure we don't write uids in wrong order. */
+ maildir_transaction_save_commit_post(t->save_ctx);
+ }
+
return ret < 0 ? -1 : maildir_sync_last_commit(ibox);
}
More information about the dovecot-cvs
mailing list