dovecot-2.2: maildir: If we see old maildir file reappear, re-re...

dovecot at dovecot.org dovecot at dovecot.org
Sun Feb 17 10:11:35 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/c92ebbedc6f9
changeset: 15817:c92ebbedc6f9
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Feb 17 10:10:45 2013 +0200
description:
maildir: If we see old maildir file reappear, re-read uidlist before logging error.
Sometimes the old file gets added back intentionally and the dovecot-uidlist
is recreated (if necessary) to give it a new UID. Existing processes should
handle this situation.

diffstat:

 src/lib-storage/index/maildir/maildir-uidlist.c |  17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diffs (41 lines):

diff -r adb9857a3879 -r c92ebbedc6f9 src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Sun Feb 17 08:50:18 2013 +0200
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Sun Feb 17 10:10:45 2013 +0200
@@ -100,6 +100,7 @@
 	unsigned int unsorted:1;
 	unsigned int have_mailbox_guid:1;
 	unsigned int opened_readonly:1;
+	unsigned int reread:1;
 };
 
 struct maildir_uidlist_sync_ctx {
@@ -871,8 +872,17 @@
 
 	*recreated_r = FALSE;
 
-	if ((ret = maildir_uidlist_stat(uidlist, &st)) <= 0)
-		return ret < 0 ? -1 : 1;
+	if ((ret = maildir_uidlist_stat(uidlist, &st)) < 0)
+		return -1;
+	if (ret == 0) {
+		*recreated_r = TRUE;
+		return 1;
+	}
+	if (uidlist->reread) {
+		uidlist->reread = FALSE;
+		*recreated_r = TRUE;
+		return 1;
+	}
 
 	if (st.st_ino != uidlist->fd_ino ||
 	    !CMP_DEV_T(st.st_dev, uidlist->fd_dev)) {
@@ -2065,6 +2075,9 @@
 	rec = hash_table_lookup(uidlist->files, filename);
 	i_assert(rec != NULL);
 
+	if ((flags & MAILDIR_UIDLIST_REC_FLAG_RACING) != 0)
+		uidlist->reread = TRUE;
+
 	rec->flags |= flags;
 }
 


More information about the dovecot-cvs mailing list