[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-save.c,
1.59, 1.60 maildir-transaction.c, 1.9, 1.10
cras at dovecot.org
cras at dovecot.org
Fri Dec 2 12:03:43 EET 2005
Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv2274
Modified Files:
maildir-save.c maildir-transaction.c
Log Message:
Logic/comments cleanups. Keep uidlist locked a bit shorter time.
Index: maildir-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-save.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- maildir-save.c 18 Sep 2005 17:01:14 -0000 1.59
+++ maildir-save.c 2 Dec 2005 10:03:41 -0000 1.60
@@ -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);
Index: maildir-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-transaction.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- maildir-transaction.c 2 Jul 2005 10:54:55 -0000 1.9
+++ maildir-transaction.c 2 Dec 2005 10:03:41 -0000 1.10
@@ -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);
}
More information about the dovecot-cvs
mailing list