dovecot-1.2: quota: Quota warnings could have been executed at i...

dovecot at dovecot.org dovecot at dovecot.org
Mon Dec 13 15:29:58 EET 2010


details:   http://hg.dovecot.org/dovecot-1.2/rev/fa6772b19795
changeset: 9636:fa6772b19795
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Dec 13 13:29:55 2010 +0000
description:
quota: Quota warnings could have been executed at incorrect times with some configs.
If target mailbox had quota ignored, the warning was sent if the mail would
have otherwise exceeded the warning threshold. Same when using multiple
quota roots where all of the roots weren't used for the target mailbox.

diffstat:

 src/plugins/quota/quota.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (35 lines):

diff -r 0b3b0cc96006 -r fa6772b19795 src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Thu Dec 09 20:49:25 2010 +0000
+++ b/src/plugins/quota/quota.c	Mon Dec 13 13:29:55 2010 +0000
@@ -893,9 +893,12 @@
 	if (ctx->failed)
 		ret = -1;
 	else if (ctx->bytes_used != 0 || ctx->count_used != 0 ||
-		 ctx->recalculate) {
+		 ctx->recalculate) T_BEGIN {
+		ARRAY_DEFINE(warn_roots, struct quota_root *);
+
 		mailbox_name = mailbox_get_name(ctx->box);
 		roots = array_get(&ctx->quota->roots, &count);
+		t_array_init(&warn_roots, count);
 		for (i = 0; i < count; i++) {
 			if (!quota_root_is_visible(roots[i], ctx->box, FALSE))
 				continue;
@@ -909,13 +912,16 @@
 
 			if (roots[i]->backend.v.update(roots[i], ctx) < 0)
 				ret = -1;
+			else
+				array_append(&warn_roots, &roots[i], 1);
 		}
 		/* execute quota warnings after all updates. this makes it
 		   work correctly regardless of whether backend.get_resource()
 		   returns updated values before backend.update() or not */
+		roots = array_get(&warn_roots, &count);
 		for (i = 0; i < count; i++)
 			quota_warnings_execute(ctx, roots[i]);
-	}
+	} T_END;
 
 	i_free(ctx);
 	return ret;


More information about the dovecot-cvs mailing list