[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-sync.c, 1.28, 1.29

cras at procontrol.fi cras at procontrol.fi
Sat Jun 19 21:43:21 EEST 2004


Update of /home/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv8978/lib-storage/index/maildir

Modified Files:
	maildir-sync.c 
Log Message:
Don't crash if we're syncing last commit to maildir, but some file was lost



Index: maildir-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-sync.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- maildir-sync.c	16 Jun 2004 00:53:37 -0000	1.28
+++ maildir-sync.c	19 Jun 2004 18:43:19 -0000	1.29
@@ -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;



More information about the dovecot-cvs mailing list