changeset 19419:66a04329b5e9

quota-clone: Avoid assert-crash when quota recalculation is triggered. Quota recalculation opened all mailboxes and got us back to quota_clone_flush(), which caused another dict transaction to be opened, which caused a crash with some dict backends.
author Timo Sirainen <tss@iki.fi>
date Thu, 26 Nov 2015 15:42:35 +0200
parents 129e61ef9de4
children db90e76f44dc
files src/plugins/quota-clone/quota-clone-plugin.c
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/quota-clone/quota-clone-plugin.c	Wed Nov 25 15:09:52 2015 +0200
+++ b/src/plugins/quota-clone/quota-clone-plugin.c	Thu Nov 26 15:42:35 2015 +0200
@@ -29,6 +29,7 @@
 struct quota_clone_mailbox {
 	union mailbox_module_context module_ctx;
 	bool quota_changed;
+	bool quota_flushing;
 };
 
 static void quota_clone_flush(struct mailbox *box)
@@ -114,8 +115,14 @@
 	struct quota_clone_mailbox *qbox = QUOTA_CLONE_CONTEXT(box);
 
 	qbox->module_ctx.super.close(box);
-	if (qbox->quota_changed)
+
+	if (qbox->quota_flushing) {
+		/* recursing back from quota recalculation */
+	} else if (qbox->quota_changed) {
+		qbox->quota_flushing = TRUE;
 		quota_clone_flush(box);
+		qbox->quota_flushing = FALSE;
+	}
 }
 
 static void quota_clone_mailbox_allocated(struct mailbox *box)