dovecot-2.0: quota: Code cleanup.
dovecot at dovecot.org
dovecot at dovecot.org
Mon Apr 4 23:19:16 EEST 2011
details: http://hg.dovecot.org/dovecot-2.0/rev/230458801916
changeset: 12714:230458801916
user: Timo Sirainen <tss at iki.fi>
date: Mon Apr 04 23:19:01 2011 +0300
description:
quota: Code cleanup.
diffstat:
src/plugins/quota/quota-private.h | 4 +++-
src/plugins/quota/quota.c | 23 ++++++++++++-----------
2 files changed, 15 insertions(+), 12 deletions(-)
diffs (77 lines):
diff -r 618f610c7c67 -r 230458801916 src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h Mon Apr 04 23:18:31 2011 +0300
+++ b/src/plugins/quota/quota-private.h Mon Apr 04 23:19:01 2011 +0300
@@ -130,7 +130,9 @@
struct mailbox *box;
int64_t bytes_used, count_used;
- uint64_t bytes_left, count_left;
+ /* 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;
struct mail *tmp_mail;
diff -r 618f610c7c67 -r 230458801916 src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c Mon Apr 04 23:18:31 2011 +0300
+++ b/src/plugins/quota/quota.c Mon Apr 04 23:19:01 2011 +0300
@@ -924,8 +924,8 @@
i_assert(ctx->quota != NULL);
ctx->box = box;
- ctx->bytes_left = (uint64_t)-1;
- ctx->count_left = (uint64_t)-1;
+ ctx->bytes_ceil = (uint64_t)-1;
+ ctx->count_ceil = (uint64_t)-1;
return ctx;
}
@@ -934,7 +934,7 @@
struct quota_root *const *roots;
const char *mailbox_name;
unsigned int i, count;
- uint64_t bytes_limit, count_limit, current, limit, left;
+ uint64_t bytes_limit, count_limit, current, limit, ceil;
int ret;
ctx->limits_set = TRUE;
@@ -958,9 +958,9 @@
QUOTA_NAME_STORAGE_BYTES,
¤t, &limit);
if (ret > 0) {
- left = limit < current ? 0 : limit - current;
- if (ctx->bytes_left > left)
- ctx->bytes_left = left;
+ ceil = limit < current ? 0 : limit - current;
+ if (ctx->bytes_ceil > ceil)
+ ctx->bytes_ceil = ceil;
} else if (ret < 0) {
ctx->failed = TRUE;
return -1;
@@ -972,9 +972,9 @@
QUOTA_NAME_MESSAGES,
¤t, &limit);
if (ret > 0) {
- left = limit < current ? 0 : limit - current;
- if (ctx->count_left > left)
- ctx->count_left = left;
+ ceil = limit < current ? 0 : limit - current;
+ if (ctx->count_ceil > ceil)
+ ctx->count_ceil = ceil;
} else if (ret < 0) {
ctx->failed = TRUE;
return -1;
@@ -1170,10 +1170,11 @@
*too_large_r = FALSE;
- if ((int64_t)ctx->count_left >= ctx->count_used + 1 &&
- (int64_t)ctx->bytes_left >= ctx->bytes_used + (off_t)size)
+ if (ctx->count_used + 1 <= (int64_t)ctx->count_ceil &&
+ ctx->bytes_used + (off_t)size <= (int64_t)ctx->bytes_ceil)
return 1;
+ /* limit reached. only thing left to do now is to set too_large_r. */
roots = array_get(&ctx->quota->roots, &count);
for (i = 0; i < count; i++) {
uint64_t bytes_limit, count_limit;
More information about the dovecot-cvs
mailing list