[dovecot-cvs] dovecot: If new/ directory is lost when syncing, assume the mail...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 12 20:06:58 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/7420a96ebc8f
changeset: 5708:7420a96ebc8f
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jun 12 20:06:51 2007 +0300
description:
If new/ directory is lost when syncing, assume the mailbox was deleted and
make the mailbox inconsistent (which disconnects the client).

diffstat:

3 files changed, 9 insertions(+), 1 deletion(-)
src/lib-storage/index/index-storage.c        |    3 ++-
src/lib-storage/index/index-storage.h        |    1 +
src/lib-storage/index/maildir/maildir-sync.c |    6 ++++++

diffs (40 lines):

diff -r f63c99fe863c -r 7420a96ebc8f src/lib-storage/index/index-storage.c
--- a/src/lib-storage/index/index-storage.c	Tue Jun 12 19:55:36 2007 +0300
+++ b/src/lib-storage/index/index-storage.c	Tue Jun 12 20:06:51 2007 +0300
@@ -458,7 +458,8 @@ bool index_storage_is_inconsistent(struc
 {
 	struct index_mailbox *ibox = (struct index_mailbox *) box;
 
-	return mail_index_view_is_inconsistent(ibox->view);
+	return mail_index_view_is_inconsistent(ibox->view) ||
+		ibox->mailbox_deleted;
 }
 
 void mail_storage_set_index_error(struct index_mailbox *ibox)
diff -r f63c99fe863c -r 7420a96ebc8f src/lib-storage/index/index-storage.h
--- a/src/lib-storage/index/index-storage.h	Tue Jun 12 19:55:36 2007 +0300
+++ b/src/lib-storage/index/index-storage.h	Tue Jun 12 20:06:51 2007 +0300
@@ -67,6 +67,7 @@ struct index_mailbox {
 	unsigned int notify_pending:1;
 	unsigned int move_to_memory:1;
 	unsigned int fsync_disable:1;
+	unsigned int mailbox_deleted:1;
 };
 
 struct index_transaction_context {
diff -r f63c99fe863c -r 7420a96ebc8f src/lib-storage/index/maildir/maildir-sync.c
--- a/src/lib-storage/index/maildir/maildir-sync.c	Tue Jun 12 19:55:36 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-sync.c	Tue Jun 12 20:06:51 2007 +0300
@@ -931,6 +931,12 @@ maildir_sync_quick_check(struct maildir_
 	*new_changed_r = *cur_changed_r = FALSE;
 
 	if (stat(new_dir, &st) < 0) {
+		if (errno == ENOENT) {
+			/* mailbox was deleted under us. this isn't the only
+			   way it can break, but the most common one. */
+			ibox->mailbox_deleted = TRUE;
+			return -1;
+		}
 		mail_storage_set_critical(&mbox->storage->storage,
 					  "stat(%s) failed: %m", new_dir);
 		return -1;


More information about the dovecot-cvs mailing list