Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3721:d46abb12934a HEAD
Logic/comments cleanups. Keep uidlist locked a bit shorter time.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 02 Dec 2005 12:03:41 +0200 |
parents | fd0986477809 |
children | eed9f0930756 |
files | src/lib-storage/index/maildir/maildir-save.c src/lib-storage/index/maildir/maildir-transaction.c |
diffstat | 2 files changed, 12 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-save.c Mon Nov 28 01:05:28 2005 +0200 +++ b/src/lib-storage/index/maildir/maildir-save.c Fri Dec 02 12:03:41 2005 +0200 @@ -359,6 +359,7 @@ i_assert(ctx->output == NULL); + /* Start syncing so that keywords_sync_ctx gets set.. */ ctx->sync_ctx = maildir_sync_index_begin(ctx->mbox); if (ctx->sync_ctx == NULL) { maildir_save_commit_abort(ctx, ctx->files); @@ -399,29 +400,22 @@ t_pop(); } - if (ret == 0) { - /* finish uidlist syncing, but keep it still locked */ - maildir_uidlist_sync_finish(ctx->uidlist_sync_ctx); - } - - if (ret < 0) { - /* deinit only if we failed. otherwise save_commit_post() - does it. */ - if (maildir_uidlist_sync_deinit(ctx->uidlist_sync_ctx) < 0) - ret = -1; - ctx->uidlist_sync_ctx = NULL; - } + if (maildir_uidlist_sync_deinit(ctx->uidlist_sync_ctx) < 0) + ret = -1; + ctx->uidlist_sync_ctx = NULL; return ret; } 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->uidlist_sync_ctx); + /* since we've allocated more UIDs, the index must be kept locked + from that time until the changes are written to transaction log. + keeping the syncing open until here we also keep the lock open. - /* to avoid deadlocks uidlist must not be left locked without index - being locked, so we can't put call to save_commit_pre(). */ + if the transaction log writer itself had to grab the lock, it'd + mean that there's a chance for another process to start maildir + sync and write the same UIDs twice for the transaction log. */ maildir_sync_index_abort(ctx->sync_ctx); pool_unref(ctx->pool);
--- a/src/lib-storage/index/maildir/maildir-transaction.c Mon Nov 28 01:05:28 2005 +0200 +++ b/src/lib-storage/index/maildir/maildir-transaction.c Fri Dec 02 12:03:41 2005 +0200 @@ -41,12 +41,10 @@ ret = -1; /* transaction is destroyed. */ + t = NULL; _t = NULL; - if (save_ctx != NULL) { - /* unlock uidlist file after writing to transaction log, - to make sure we don't write uids in wrong order. */ + if (save_ctx != NULL) maildir_transaction_save_commit_post(save_ctx); - } return ret < 0 ? -1 : maildir_sync_last_commit(mbox); }