[dovecot-cvs] dovecot/src/plugins/quota quota-dict.c, 1.9.2.1,
1.9.2.2 quota-dirsize.c, 1.10, 1.10.2.1 quota-fs.c, 1.14,
1.14.2.1 quota-maildir.c, 1.9.2.1, 1.9.2.2 quota-private.h,
1.7, 1.7.2.1 quota-storage.c, 1.6.2.1, 1.6.2.2 quota.c,
1.8.2.1, 1.8.2.2 quota.h, 1.4, 1.4.2.1
tss-movial at dovecot.org
tss-movial at dovecot.org
Sun Jun 11 20:34:51 EEST 2006
Update of /var/lib/cvs/dovecot/src/plugins/quota
In directory talvi:/tmp/cvs-serv22103
Modified Files:
Tag: branch_1_0
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.9.2.1
retrieving revision 1.9.2.2
diff -u -d -r1.9.2.1 -r1.9.2.2
--- quota-dict.c 8 Jun 2006 20:25:00 -0000 1.9.2.1
+++ quota-dict.c 11 Jun 2006 17:34:48 -0000 1.9.2.2
@@ -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.10.2.1
diff -u -d -r1.10 -r1.10.2.1
--- quota-dirsize.c 13 Apr 2006 19:31:35 -0000 1.10
+++ quota-dirsize.c 11 Jun 2006 17:34:48 -0000 1.10.2.1
@@ -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.14.2.1
diff -u -d -r1.14 -r1.14.2.1
--- quota-fs.c 14 Apr 2006 11:00:07 -0000 1.14
+++ quota-fs.c 11 Jun 2006 17:34:48 -0000 1.14.2.1
@@ -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.2.1
retrieving revision 1.9.2.2
diff -u -d -r1.9.2.1 -r1.9.2.2
--- quota-maildir.c 11 Jun 2006 14:06:12 -0000 1.9.2.1
+++ quota-maildir.c 11 Jun 2006 17:34:48 -0000 1.9.2.2
@@ -695,6 +695,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.7
retrieving revision 1.7.2.1
diff -u -d -r1.7 -r1.7.2.1
--- quota-private.h 6 Mar 2006 15:48:33 -0000 1.7
+++ quota-private.h 11 Jun 2006 17:34:48 -0000 1.7.2.1
@@ -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,
@@ -118,10 +120,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.6.2.1
retrieving revision 1.6.2.2
diff -u -d -r1.6.2.1 -r1.6.2.2
--- quota-storage.c 11 Jun 2006 16:11:46 -0000 1.6.2.1
+++ quota-storage.c 11 Jun 2006 17:34:48 -0000 1.6.2.2
@@ -183,7 +183,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.2.1
retrieving revision 1.8.2.2
diff -u -d -r1.8.2.1 -r1.8.2.2
--- quota.c 8 Jun 2006 20:22:03 -0000 1.8.2.1
+++ quota.c 11 Jun 2006 17:34:48 -0000 1.8.2.2
@@ -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.4.2.1
diff -u -d -r1.4 -r1.4.2.1
--- quota.h 1 Mar 2006 09:15:03 -0000 1.4
+++ quota.h 11 Jun 2006 17:34:48 -0000 1.4.2.1
@@ -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