Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2173:9438951e243f HEAD
Don't crash if we're syncing last commit to maildir, but some file was lost
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 19 Jun 2004 21:43:19 +0300 |
parents | cee8c4354b20 |
children | 814f55aea322 |
files | src/lib-storage/index/maildir/maildir-sync.c |
diffstat | 1 files changed, 21 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-sync.c Sat Jun 19 21:36:25 2004 +0300 +++ b/src/lib-storage/index/maildir/maildir-sync.c Sat Jun 19 21:43:19 2004 +0300 @@ -339,6 +339,7 @@ memset(&ctx, 0, sizeof(ctx)); ctx.ibox = ibox; + ibox->syncing_commit = TRUE; ret = mail_index_sync_begin(ibox->index, &ctx.sync_ctx, &ctx.view, ibox->commit_log_file_seq, ibox->commit_log_file_offset); @@ -361,6 +362,7 @@ if (mail_index_sync_end(ctx.sync_ctx) < 0) ret = -1; } + ibox->syncing_commit = FALSE; if (ret == 0) { ibox->commit_log_file_seq = 0; @@ -843,14 +845,21 @@ file list into uidlist. alternative would be to lock it when new files are found, but - the directory scans _must_ be restarted then */ - if ((ret = maildir_uidlist_try_lock(ctx->ibox->uidlist)) < 0) - return ret; - if (ret == 0 && !forced) { - /* we didn't get a lock, don't do syncing unless we really - want to check for expunges or renames. new files won't - be added. */ - return 0; + the directory scans _must_ be restarted then. + + if we got here through maildir_sync_last_commit(), we can't sync + index as it's already being synced. so, don't try locking uidlist + either, we only want to find new filename for some mail. + */ + if (!ctx->ibox->syncing_commit) { + if ((ret = maildir_uidlist_try_lock(ctx->ibox->uidlist)) < 0) + return ret; + if (ret == 0 && !forced) { + /* we didn't get a lock, don't do syncing unless we + really want to check for expunges or renames. new + files won't be added. */ + return 0; + } } ctx->partial = !cur_changed; @@ -866,8 +875,10 @@ /* finish uidlist syncing, but keep it still locked */ maildir_uidlist_sync_finish(ctx->uidlist_sync_ctx); - if (maildir_sync_index(ctx) < 0) - return -1; + if (!ctx->ibox->syncing_commit) { + if (maildir_sync_index(ctx) < 0) + return -1; + } ret = maildir_uidlist_sync_deinit(ctx->uidlist_sync_ctx); ctx->uidlist_sync_ctx = NULL;