dovecot: Quota warnings may have been triggered too early.

dovecot at dovecot.org dovecot at dovecot.org
Fri Dec 21 18:40:39 EET 2007


details:   http://hg.dovecot.org/dovecot/rev/71b9541adad1
changeset: 7011:71b9541adad1
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Dec 21 18:40:10 2007 +0200
description:
Quota warnings may have been triggered too early.

diffstat:

1 file changed, 8 insertions(+), 7 deletions(-)
src/plugins/quota/quota.c |   15 ++++++++-------

diffs (43 lines):

diff -r e78c47c6ee8e -r 71b9541adad1 src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Fri Dec 21 18:21:31 2007 +0200
+++ b/src/plugins/quota/quota.c	Fri Dec 21 18:40:10 2007 +0200
@@ -636,8 +636,7 @@ static void quota_warning_execute(const 
 	}
 }
 
-static void quota_warnings_execute(struct quota_root *root,
-				   struct quota_transaction_context *ctx)
+static void quota_warnings_execute(struct quota_root *root)
 {
 	struct quota_warning_rule *warnings;
 	unsigned int i, count;
@@ -656,11 +655,9 @@ static void quota_warnings_execute(struc
 
 	for (i = 0; i < count; i++) {
 		if ((bytes_current < warnings[i].bytes_limit &&
-		     bytes_current +
-		     ctx->bytes_used >= warnings[i].bytes_limit) ||
+		     bytes_current >= warnings[i].bytes_limit) ||
 		    (count_current < warnings[i].count_limit &&
-		     count_current +
-		     ctx->count_used >= warnings[i].count_limit)) {
+		     count_current >= warnings[i].count_limit)) {
 			quota_warning_execute(warnings[i].command);
 			break;
 		}
@@ -682,10 +679,14 @@ int quota_transaction_commit(struct quot
 		 ctx->recalculate) {
 		roots = array_get(&ctx->quota->roots, &count);
 		for (i = 0; i < count; i++) {
-			quota_warnings_execute(roots[i], ctx);
 			if (roots[i]->backend.v.update(roots[i], ctx) < 0)
 				ret = -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 */
+		for (i = 0; i < count; i++)
+			quota_warnings_execute(roots[i]);
 	}
 
 	i_free(ctx);


More information about the dovecot-cvs mailing list