# HG changeset patch # User Timo Sirainen # Date 1198255210 -7200 # Node ID 71b9541adad115ee30abf08efa9cba434d9128b9 # Parent e78c47c6ee8e8aa3845d371f11400956e68b2140 Quota warnings may have been triggered too early. 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_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 @@ 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 @@ 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);