dovecot-2.0: Mailbox deletion: Delay marking its index deleted u...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 7 19:07:09 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/3a0601cb9e67
changeset: 11487:3a0601cb9e67
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jun 07 14:05:42 2010 +0100
description:
Mailbox deletion: Delay marking its index deleted until ACL has had a chance to abort the deletion.

diffstat:

 src/lib-storage/index/index-storage.c          |   3 +++
 src/lib-storage/mail-storage-private.h         |   1 +
 src/lib-storage/mail-storage.c                 |   6 +-----
 src/plugins/lazy-expunge/lazy-expunge-plugin.c |  11 +++++++++--
 4 files changed, 14 insertions(+), 7 deletions(-)

diffs (76 lines):

diff -r 6f5d3e035652 -r 3a0601cb9e67 src/lib-storage/index/index-storage.c
--- a/src/lib-storage/index/index-storage.c	Sat Jun 05 13:38:17 2010 +0100
+++ b/src/lib-storage/index/index-storage.c	Mon Jun 07 14:05:42 2010 +0100
@@ -462,6 +462,9 @@
 		return index_storage_mailbox_delete_dir(box, FALSE);
 	}
 
+	if (mailbox_mark_index_deleted(box, TRUE) < 0)
+		return -1;
+
 	if (mailbox_get_guid(box, mailbox_guid) < 0)
 		return -1;
 
diff -r 6f5d3e035652 -r 3a0601cb9e67 src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h	Sat Jun 05 13:38:17 2010 +0100
+++ b/src/lib-storage/mail-storage-private.h	Mon Jun 07 14:05:42 2010 +0100
@@ -463,6 +463,7 @@
 int mail_set_aborted(struct mail *mail);
 void mail_set_expunged(struct mail *mail);
 void mailbox_set_deleted(struct mailbox *box);
+int mailbox_mark_index_deleted(struct mailbox *box, bool del);
 void mailbox_refresh_permissions(struct mailbox *box);
 
 /* Returns -1 if error, 0 if failed with EEXIST, 1 if ok */
diff -r 6f5d3e035652 -r 3a0601cb9e67 src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c	Sat Jun 05 13:38:17 2010 +0100
+++ b/src/lib-storage/mail-storage.c	Mon Jun 07 14:05:42 2010 +0100
@@ -664,7 +664,7 @@
 	return box->v.update(box, update);
 }
 
-static int mailbox_mark_index_deleted(struct mailbox *box, bool del)
+int mailbox_mark_index_deleted(struct mailbox *box, bool del)
 {
 	enum mail_index_transaction_flags trans_flags = 0;
 	struct mail_index_transaction *trans;
@@ -737,10 +737,6 @@
 		}
 	}
 
-	if (box->opened) {
-		if (mailbox_mark_index_deleted(box, TRUE) < 0)
-			return -1;
-	}
 	ret = box->v.delete(box);
 
 	box->deleting = FALSE;
diff -r 6f5d3e035652 -r 3a0601cb9e67 src/plugins/lazy-expunge/lazy-expunge-plugin.c
--- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c	Sat Jun 05 13:38:17 2010 +0100
+++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c	Mon Jun 07 14:05:42 2010 +0100
@@ -373,8 +373,11 @@
 	char timestamp[256];
 	int ret;
 
-	if (llist->internal_namespace)
+	if (llist->internal_namespace || !box->opened) {
+		/* a) deleting mailbox from lazy_expunge namespaces
+		   b) deleting a \noselect mailbox */
 		return lbox->super.delete(box);
+	}
 
 	expunge_ns = get_lazy_ns(list->ns->user, LAZY_NAMESPACE_EXPUNGE);
 	dest_ns = get_lazy_ns(list->ns->user, LAZY_NAMESPACE_DELETE);
@@ -393,7 +396,11 @@
 		destname = t_strconcat(box->name, "-", timestamp, NULL);
 	}
 
-	/* first move the actual mailbox */
+	/* avoid potential race conditions by marking it deleted */
+	if (mailbox_mark_index_deleted(box, TRUE) < 0)
+		return -1;
+
+	/* rename it into the lazy_expunge namespace */
 	ret = mailbox_move(box, dest_ns->list, destname, &expunge_box);
 	if (ret < 0)
 		return -1;


More information about the dovecot-cvs mailing list