]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota plugin optimization: Don't look up quota values every time when iterating quota...
authorTimo Sirainen <tss@iki.fi>
Sat, 17 Jan 2009 17:30:54 +0000 (12:30 -0500)
committerTimo Sirainen <tss@iki.fi>
Sat, 17 Jan 2009 17:30:54 +0000 (12:30 -0500)
--HG--
branch : HEAD

src/plugins/quota/quota-private.h
src/plugins/quota/quota.c

index 30136b0b57ce204b54a38ae59a400278c1e07517..24b6f557791f9f3ec9cffc8afc6ac09d4b18b5b2 100644 (file)
@@ -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);
index f61cafcf2794cda75291daa1a5aee7f4b8a8a8d2..9f4fe37711a83d7453df23859b47638a592901b4 100644 (file)
@@ -142,6 +142,7 @@ quota_root_init(struct quota_root_settings *root_set, struct quota *quota)
        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(struct quota_root_iter *iter)
                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;