[dovecot-cvs] dovecot/src/plugins/quota quota-dict.c, 1.10,
1.11 quota-dirsize.c, 1.10, 1.11 quota-fs.c, 1.14,
1.15 quota-maildir.c, 1.9, 1.10 quota-private.h, 1.8,
1.9 quota-storage.c, 1.8, 1.9 quota.c, 1.8, 1.9 quota.h, 1.4, 1.5
tss-movial at dovecot.org
tss-movial at dovecot.org
Sun Jun 11 20:39:08 EEST 2006
Update of /var/lib/cvs/dovecot/src/plugins/quota
In directory talvi:/tmp/cvs-serv4871
Modified Files:
quota-dict.c quota-dirsize.c quota-fs.c quota-maildir.c
quota-private.h quota-storage.c quota.c quota.h
Log Message:
If size of the mail was known before saving started, we allocated
the quota twice for it.
Index: quota-dict.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-dict.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- quota-dict.c 11 Jun 2006 17:38:06 -0000 1.10
+++ quota-dict.c 11 Jun 2006 17:39:04 -0000 1.11
@@ -223,6 +223,7 @@
quota_default_try_alloc,
quota_default_try_alloc_bytes,
+ quota_default_test_alloc_bytes,
quota_default_alloc,
quota_default_free
}
Index: quota-dirsize.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-dirsize.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- quota-dirsize.c 13 Apr 2006 19:31:35 -0000 1.10
+++ quota-dirsize.c 11 Jun 2006 17:39:04 -0000 1.11
@@ -313,6 +313,7 @@
quota_default_try_alloc,
quota_default_try_alloc_bytes,
+ quota_default_test_alloc_bytes,
quota_default_alloc,
quota_default_free
}
Index: quota-fs.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-fs.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- quota-fs.c 14 Apr 2006 11:00:07 -0000 1.14
+++ quota-fs.c 11 Jun 2006 17:39:04 -0000 1.15
@@ -268,6 +268,7 @@
quota_default_try_alloc,
quota_default_try_alloc_bytes,
+ quota_default_test_alloc_bytes,
quota_default_alloc,
quota_default_free
}
Index: quota-maildir.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-maildir.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- quota-maildir.c 2 May 2006 20:11:08 -0000 1.9
+++ quota-maildir.c 11 Jun 2006 17:39:04 -0000 1.10
@@ -687,6 +687,7 @@
quota_default_try_alloc,
quota_default_try_alloc_bytes,
+ quota_default_test_alloc_bytes,
quota_default_alloc,
quota_default_free
}
Index: quota-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-private.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- quota-private.h 9 May 2006 11:57:49 -0000 1.8
+++ quota-private.h 11 Jun 2006 17:39:04 -0000 1.9
@@ -51,6 +51,8 @@
struct mail *mail, bool *too_large_r);
int (*try_alloc_bytes)(struct quota_root_transaction_context *ctx,
uoff_t size, bool *too_large_r);
+ int (*test_alloc_bytes)(struct quota_root_transaction_context *ctx,
+ uoff_t size, bool *too_large_r);
void (*alloc)(struct quota_root_transaction_context *ctx,
struct mail *mail);
void (*free)(struct quota_root_transaction_context *ctx,
@@ -119,10 +121,12 @@
/* default simple implementations for bytes/count updating */
void
quota_default_transaction_rollback(struct quota_root_transaction_context *ctx);
-int quota_default_try_alloc_bytes(struct quota_root_transaction_context *ctx,
- uoff_t size, bool *too_large_r);
int quota_default_try_alloc(struct quota_root_transaction_context *ctx,
struct mail *mail, bool *too_large_r);
+int quota_default_try_alloc_bytes(struct quota_root_transaction_context *ctx,
+ uoff_t size, bool *too_large_r);
+int quota_default_test_alloc_bytes(struct quota_root_transaction_context *ctx,
+ uoff_t size, bool *too_large_r);
void quota_default_alloc(struct quota_root_transaction_context *ctx,
struct mail *mail);
void quota_default_free(struct quota_root_transaction_context *ctx,
Index: quota-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-storage.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- quota-storage.c 11 Jun 2006 16:12:38 -0000 1.8
+++ quota-storage.c 11 Jun 2006 17:39:04 -0000 1.9
@@ -186,7 +186,7 @@
full mail. */
bool too_large;
- ret = quota_try_alloc_bytes(qt, st->st_size, &too_large);
+ ret = quota_test_alloc_bytes(qt, st->st_size, &too_large);
if (ret == 0) {
mail_storage_set_error(t->box->storage,
"Quota exceeded");
Index: quota.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- quota.c 6 Mar 2006 15:48:33 -0000 1.8
+++ quota.c 11 Jun 2006 17:39:04 -0000 1.9
@@ -324,6 +324,25 @@
return ret;
}
+int quota_test_alloc_bytes(struct quota_transaction_context *ctx,
+ uoff_t size, bool *too_large_r)
+{
+ struct quota_root_transaction_context *const *root_transactions;
+ unsigned int i, count;
+ int ret = 1;
+
+ root_transactions = array_get(&ctx->root_transactions, &count);
+ for (i = 0; i < count; i++) {
+ struct quota_root_transaction_context *t =
+ root_transactions[i];
+
+ ret = t->root->v.test_alloc_bytes(t, size, too_large_r);
+ if (ret <= 0)
+ break;
+ }
+ return ret;
+}
+
void quota_alloc(struct quota_transaction_context *ctx, struct mail *mail)
{
struct quota_root_transaction_context *const *root_transactions;
@@ -372,6 +391,20 @@
int quota_default_try_alloc_bytes(struct quota_root_transaction_context *ctx,
uoff_t size, bool *too_large_r)
{
+ int ret;
+
+ ret = quota_default_test_alloc_bytes(ctx, size, too_large_r);
+ if (ret <= 0 || ctx->disabled)
+ return ret;
+
+ ctx->count_diff++;
+ ctx->bytes_diff += size;
+ return 1;
+}
+
+int quota_default_test_alloc_bytes(struct quota_root_transaction_context *ctx,
+ uoff_t size, bool *too_large_r)
+{
if (ctx->disabled) {
*too_large_r = FALSE;
return 1;
@@ -387,9 +420,6 @@
return 0;
if (ctx->count_current + ctx->count_diff + 1 > ctx->count_limit)
return 0;
-
- ctx->count_diff++;
- ctx->bytes_diff += size;
return 1;
}
Index: quota.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- quota.h 1 Mar 2006 09:15:03 -0000 1.4
+++ quota.h 11 Jun 2006 17:39:04 -0000 1.5
@@ -65,6 +65,9 @@
struct mail *mail, bool *too_large_r);
int quota_try_alloc_bytes(struct quota_transaction_context *ctx,
uoff_t size, bool *too_large_r);
+/* Like quota_try_alloc_bytes(), but don't actually update the quota. */
+int quota_test_alloc_bytes(struct quota_transaction_context *ctx,
+ uoff_t size, bool *too_large_r);
/* Update quota by allocating/freeing space used by mail. */
void quota_alloc(struct quota_transaction_context *ctx, struct mail *mail);
void quota_free(struct quota_transaction_context *ctx, struct mail *mail);
More information about the dovecot-cvs
mailing list