]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Remove quota_over_flag_* from quota_root.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 7 Feb 2017 13:33:07 +0000 (15:33 +0200)
committerGitLab <gitlab@git.dovecot.net>
Mon, 13 Feb 2017 10:52:05 +0000 (12:52 +0200)
They are used only in one specific location and don't need to be stored
permanently.

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

index 2b1b9e405928b63711830b11558a248472303e43..351eebe43b3c221233e2f56e7c6d930ffadf44e1 100644 (file)
@@ -131,10 +131,6 @@ struct quota_root {
        /* Module-specific contexts. See quota_module_id. */
        ARRAY(void) quota_module_contexts;
 
-       /* Set to the current quota_over_flag, regardless of whether
-          it matches quota_over_flag_value mask. */
-       const char *quota_over_flag;
-
        /* don't enforce quota when saving */
        bool no_enforcing:1;
        /* quota is automatically updated. update() should be called but the
@@ -146,10 +142,6 @@ struct quota_root {
        bool recounting:1;
        /* Quota root is hidden (to e.g. IMAP GETQUOTAROOT) */
        bool hidden:1;
-       /* Is quota_over_flag* initialized yet? */
-       bool quota_over_flag_initialized:1;
-       /* Is user currently over quota? */
-       bool quota_over_flag_status:1;
        /* Did we already check quota_over_flag correctness? */
        bool quota_over_flag_checked:1;
 };
index 0fd66ee2b3f5a1671326d470b65df1fbd810bfde..868a8cc509bed50a51c18ffdd62b40f2a1cc997b 100644 (file)
@@ -1025,13 +1025,14 @@ int quota_transaction_commit(struct quota_transaction_context **_ctx)
        return ret;
 }
 
-static void quota_over_flag_init_root(struct quota_root *root)
+static void quota_over_flag_init_root(struct quota_root *root,
+                                     const char **quota_over_flag_r,
+                                     bool *status_r)
 {
        const char *name, *flag_mask;
 
-       if (root->quota_over_flag_initialized)
-               return;
-       root->quota_over_flag_initialized = TRUE;
+       *quota_over_flag_r = NULL;
+       *status_r = FALSE;
 
        /* e.g.: quota_over_flag_value=TRUE or quota_over_flag_value=*  */
        name = t_strconcat(root->set->set_name, "_over_flag_value", NULL);
@@ -1039,22 +1040,22 @@ static void quota_over_flag_init_root(struct quota_root *root)
        if (flag_mask == NULL)
                return;
 
-       /* compare quota_over_flag's value to quota_over_flag_value and
-          save the result. */
+       /* compare quota_over_flag's value (that comes from userdb) to
+          quota_over_flag_value and save the result. */
        name = t_strconcat(root->set->set_name, "_over_flag", NULL);
-       root->quota_over_flag = p_strdup_empty(root->pool,
-               mail_user_plugin_getenv(root->quota->user, name));
-       root->quota_over_flag_status = root->quota_over_flag != NULL &&
-               wildcard_match_icase(root->quota_over_flag, flag_mask);
+       *quota_over_flag_r = mail_user_plugin_getenv(root->quota->user, name);
+       *status_r = *quota_over_flag_r != NULL &&
+               wildcard_match_icase(*quota_over_flag_r, flag_mask);
 }
 
 static void quota_over_flag_check_root(struct quota_root *root)
 {
-       const char *name, *overquota_script;
+       const char *name, *overquota_script, *quota_over_flag;
        const char *const *resources;
        unsigned int i;
        uint64_t value, limit;
        bool cur_overquota = FALSE;
+       bool quota_over_status;
        int ret;
 
        if (root->quota_over_flag_checked)
@@ -1071,7 +1072,7 @@ static void quota_over_flag_check_root(struct quota_root *root)
                return;
        }
        root->quota_over_flag_checked = TRUE;
-       quota_over_flag_init_root(root);
+       quota_over_flag_init_root(root, &quota_over_flag, &quota_over_status);
 
        resources = quota_root_get_resources(root);
        for (i = 0; resources[i] != NULL; i++) {
@@ -1095,16 +1096,16 @@ static void quota_over_flag_check_root(struct quota_root *root)
        }
        if (root->quota->set->debug) {
                i_debug("quota: quota_over_flag=%d(%s) vs currently overquota=%d",
-                       root->quota_over_flag_status ? 1 : 0,
-                       root->quota_over_flag == NULL ? "(null)" : root->quota_over_flag,
+                       quota_over_status ? 1 : 0,
+                       quota_over_flag == NULL ? "(null)" : quota_over_flag,
                        cur_overquota ? 1 : 0);
        }
-       if (cur_overquota != root->quota_over_flag_status) {
+       if (cur_overquota != quota_over_status) {
                name = t_strconcat(root->set->set_name, "_over_script", NULL);
                overquota_script = mail_user_plugin_getenv(root->quota->user, name);
                if (overquota_script != NULL) {
                        quota_warning_execute(root, overquota_script,
-                                             root->quota_over_flag,
+                                             quota_over_flag,
                                              "quota_over_flag mismatch");
                }
        }