dovecot-1.2: quota plugin optimization: Don't look up quota valu...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jan 17 20:56:34 EET 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/a90d1488bacf
changeset: 8645:a90d1488bacf
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Jan 17 12:30:54 2009 -0500
description:
quota plugin optimization: Don't look up quota values every time when iterating quota roots.

diffstat:

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

diffs (46 lines):

diff -r bf53ab94db72 -r a90d1488bacf src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h	Sat Jan 17 11:57:56 2009 -0500
+++ b/src/plugins/quota/quota-private.h	Sat Jan 17 12:30:54 2009 -0500
@@ -100,6 +100,9 @@ struct quota_root {
 	   may change these by reading the limits elsewhere (e.g. Maildir++,
 	   FS quota) */
 	int64_t bytes_limit, count_limit;
+	/* 1 = quota root has resources and should be returned when iterating
+	   quota roots, 0 = not, -1 = unknown. */
+	int resource_ret;
 
 	/* Module-specific contexts. See quota_module_id. */
 	ARRAY_DEFINE(quota_module_contexts, void);
diff -r bf53ab94db72 -r a90d1488bacf src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Sat Jan 17 11:57:56 2009 -0500
+++ b/src/plugins/quota/quota.c	Sat Jan 17 12:30:54 2009 -0500
@@ -142,6 +142,7 @@ quota_root_init(struct quota_root_settin
 	const char *const *tmp;
 
 	root = root_set->backend->v.alloc();
+	root->resource_ret = -1;
 	root->pool = pool_alloconly_create("quota root", 512);
 	root->set = root_set;
 	root->quota = quota;
@@ -622,14 +623,18 @@ struct quota_root *quota_root_iter_next(
 		if (!quota_root_is_visible(roots[iter->i], iter->box, FALSE))
 			continue;
 
-		ret = quota_get_resource(roots[iter->i], "",
-					 QUOTA_NAME_STORAGE_KILOBYTES,
-					 &value, &limit);
+		ret = roots[iter->i]->resource_ret;
+		if (ret == -1) {
+			ret = quota_get_resource(roots[iter->i], "",
+						 QUOTA_NAME_STORAGE_KILOBYTES,
+						 &value, &limit);
+		}
 		if (ret == 0) {
 			ret = quota_get_resource(roots[iter->i], "",
 						 QUOTA_NAME_MESSAGES,
 						 &value, &limit);
 		}
+		roots[iter->i]->resource_ret = ret;
 		if (ret > 0) {
 			root = roots[iter->i];
 			break;


More information about the dovecot-cvs mailing list