changeset 22180:d48b39c113d0

quota: quota_root_iter_next() - Iterate all visible roots Don't try to skip the roots that don't have an active quota. imap_quota plugin does the skipping now itself, and quota_clone shouldn't really be even used with more than one quota root.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 08 Jun 2017 20:25:11 +0300
parents 549b74a60b5c
children 876f2875287f
files src/plugins/quota/quota-private.h src/plugins/quota/quota.c
diffstat 2 files changed, 2 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/quota/quota-private.h	Thu Jun 08 20:24:26 2017 +0300
+++ b/src/plugins/quota/quota-private.h	Thu Jun 08 20:25:11 2017 +0300
@@ -125,9 +125,6 @@
 	   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(void) quota_module_contexts;
--- a/src/plugins/quota/quota.c	Thu Jun 08 20:24:26 2017 +0300
+++ b/src/plugins/quota/quota.c	Thu Jun 08 20:25:11 2017 +0300
@@ -398,7 +398,6 @@
 	struct quota_root *root;
 
 	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;
@@ -683,8 +682,6 @@
 {
 	struct quota_root *const *roots, *root = NULL;
 	unsigned int count;
-	uint64_t value, limit;
-	int ret;
 
 	if (iter->quota == NULL)
 		return NULL;
@@ -697,22 +694,8 @@
 		if (!quota_root_is_visible(roots[iter->i], iter->box, FALSE))
 			continue;
 
-		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;
-		}
+		root = roots[iter->i];
+		break;
 	}
 
 	iter->i++;