dovecot-2.1: quota: Set to quota transaction how many bytes/mess...

dovecot at dovecot.org dovecot at dovecot.org
Tue Apr 24 21:09:53 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/ec8564741aa8
changeset: 14471:ec8564741aa8
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Apr 24 21:03:19 2012 +0300
description:
quota: Set to quota transaction how many bytes/messages we're over quota.

diffstat:

 src/plugins/quota/quota-private.h |   3 +++
 src/plugins/quota/quota.c         |  28 +++++++++++++++++++++-------
 2 files changed, 24 insertions(+), 7 deletions(-)

diffs (65 lines):

diff -r 6607e35dd8d2 -r ec8564741aa8 src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h	Mon Apr 23 17:59:39 2012 +0300
+++ b/src/plugins/quota/quota-private.h	Tue Apr 24 21:03:19 2012 +0300
@@ -133,6 +133,9 @@
 	/* how many bytes/mails can be saved until limit is reached.
 	   (set once, not updated by bytes_used/count_used) */
 	uint64_t bytes_ceil, count_ceil;
+	/* how many bytes/mails we are over quota (either *_ceil or *_over
+	   is always zero) */
+	uint64_t bytes_over, count_over;
 
 	struct mail *tmp_mail;
 
diff -r 6607e35dd8d2 -r ec8564741aa8 src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Mon Apr 23 17:59:39 2012 +0300
+++ b/src/plugins/quota/quota.c	Tue Apr 24 21:03:19 2012 +0300
@@ -940,7 +940,7 @@
 	struct quota_root *const *roots;
 	const char *mailbox_name;
 	unsigned int i, count;
-	uint64_t bytes_limit, count_limit, current, limit, ceil;
+	uint64_t bytes_limit, count_limit, current, limit, diff;
 	int ret;
 
 	ctx->limits_set = TRUE;
@@ -964,9 +964,16 @@
 						 QUOTA_NAME_STORAGE_BYTES,
 						 &current, &limit);
 			if (ret > 0) {
-				ceil = limit < current ? 0 : limit - current;
-				if (ctx->bytes_ceil > ceil)
-					ctx->bytes_ceil = ceil;
+				if (limit < current) {
+					ctx->bytes_ceil = 0;
+					diff = current - limit;
+					if (ctx->bytes_over < diff)
+						ctx->bytes_over = diff;
+				} else {
+					diff = limit - current;
+					if (ctx->bytes_ceil > diff)
+						ctx->bytes_ceil = diff;
+				}
 			} else if (ret < 0) {
 				ctx->failed = TRUE;
 				return -1;
@@ -978,9 +985,16 @@
 						 QUOTA_NAME_MESSAGES,
 						 &current, &limit);
 			if (ret > 0) {
-				ceil = limit < current ? 0 : limit - current;
-				if (ctx->count_ceil > ceil)
-					ctx->count_ceil = ceil;
+				if (limit < current) {
+					ctx->count_ceil = 0;
+					diff = current - limit;
+					if (ctx->count_over < diff)
+						ctx->count_over = diff;
+				} else {
+					diff = limit - current;
+					if (ctx->count_ceil > diff)
+						ctx->count_ceil = diff;
+				}
 			} else if (ret < 0) {
 				ctx->failed = TRUE;
 				return -1;


More information about the dovecot-cvs mailing list