From: Timo Sirainen Date: Tue, 7 Feb 2017 13:33:07 +0000 (+0200) Subject: quota: Remove quota_over_flag_* from quota_root. X-Git-Tag: 2.3.0.rc1~2139 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4009eb0bbe343958c22772bc0be88d17ee1c33fe;p=thirdparty%2Fdovecot%2Fcore.git quota: Remove quota_over_flag_* from quota_root. They are used only in one specific location and don't need to be stored permanently. --- diff --git a/src/plugins/quota/quota-private.h b/src/plugins/quota/quota-private.h index 2b1b9e4059..351eebe43b 100644 --- a/src/plugins/quota/quota-private.h +++ b/src/plugins/quota/quota-private.h @@ -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; }; diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index 0fd66ee2b3..868a8cc509 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -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, "a_over_flag, "a_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"); } }