]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dict, last-login: Moved no_slowness_warning into dict_op_settings
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 1 Apr 2022 14:43:03 +0000 (17:43 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 25 Apr 2022 09:07:11 +0000 (09:07 +0000)
Now that we have such op-specific settings, it makes no sense having a
separate function for this.

src/lib-dict/dict-client.c
src/lib-dict/dict-private.h
src/lib-dict/dict.c
src/lib-dict/dict.h
src/plugins/last-login/last-login-plugin.c

index 57344d27fc548736508221162989c8bfb5a3d521..cccef15b5317c2888fe0067753d1de80fd4b1f63 100644 (file)
@@ -1335,7 +1335,7 @@ client_dict_transaction_commit_callback(struct client_dict_cmd *cmd,
                /* include timing info always in error messages */
                result.error = t_strdup_printf("%s (reply took %s)",
                        result.error, dict_warnings_sec(cmd, diff, extra_args));
-       } else if (!cmd->background && !cmd->trans->ctx.no_slowness_warning &&
+       } else if (!cmd->background && !cmd->trans->ctx.set.no_slowness_warning &&
                   diff >= (int)dict->warn_slow_msecs) {
                e_warning(dict->conn.conn.event, "dict commit took %s: "
                          "%s (%u commands, first: %s)",
index 16ca1d78df8d7b727431147a44be85d366af000e..83aeb854a6b5a8034e2ad10b767a1bcf3f40b421 100644 (file)
@@ -56,6 +56,7 @@ struct dict_commit_callback_ctx;
 struct dict_op_settings_private {
        char *username;
        char *home_dir;
+       bool no_slowness_warning;
 };
 
 struct dict {
@@ -94,7 +95,6 @@ struct dict_transaction_context {
        struct timespec timestamp;
 
        bool changed:1;
-       bool no_slowness_warning:1;
 };
 
 void dict_transaction_commit_async_noop_callback(
index 7b49a23f01162362c85823865498bfbfa424d57a..3be0a852ae7afd92fbcbde5959816d30a53bfb00 100644 (file)
@@ -526,11 +526,6 @@ dict_transaction_begin(struct dict *dict, const struct dict_op_settings *set)
        return ctx;
 }
 
-void dict_transaction_no_slowness_warning(struct dict_transaction_context *ctx)
-{
-       ctx->no_slowness_warning = TRUE;
-}
-
 void dict_transaction_set_timestamp(struct dict_transaction_context *ctx,
                                    const struct timespec *ts)
 {
@@ -774,6 +769,7 @@ void dict_op_settings_dup(const struct dict_op_settings *source,
        i_zero(dest_r);
        dest_r->username = i_strdup(source->username);
        dest_r->home_dir = i_strdup(source->home_dir);
+       dest_r->no_slowness_warning = source->no_slowness_warning;
 }
 
 void dict_op_settings_private_free(struct dict_op_settings_private *set)
index a985661eb290262add9e2aafdeecf6117fadd169..cd2e70b72f6702c4999d418a387696e40a621ece 100644 (file)
@@ -41,6 +41,12 @@ struct dict_op_settings {
        const char *username;
        /* home directory for the user, if known */
        const char *home_dir;
+
+       /* Don't log a warning if the transaction commit took a long time.
+          This is needed if there are no guarantees that an asynchronous
+          commit will finish up anytime soon. Mainly useful for transactions
+          which aren't especially important whether they finish or not. */
+       bool no_slowness_warning;
 };
 
 struct dict_lookup_result {
@@ -155,11 +161,6 @@ int dict_iterate_deinit(struct dict_iterate_context **ctx, const char **error_r)
 /* Start a new dictionary transaction. */
 struct dict_transaction_context *
 dict_transaction_begin(struct dict *dict, const struct dict_op_settings *set);
-/* Don't log a warning if the transaction commit took a long time.
-   This is needed if there are no guarantees that an asynchronous commit will
-   finish up anytime soon. Mainly useful for transactions which aren't
-   especially important whether they finish or not. */
-void dict_transaction_no_slowness_warning(struct dict_transaction_context *ctx);
 /* Set write timestamp for the entire transaction. This must be set before
    any changes are done and can't be changed afterwards. Currently only
    dict-sql with Cassandra backend does anything with this. */
index 1f580b9ae507060aaa964ad54b17c4fe32992413..5a1257619be7864bd3f73b91fe07b027faa31749 100644 (file)
@@ -119,8 +119,9 @@ static void last_login_mail_user_created(struct mail_user *user)
 
        precision = mail_user_plugin_getenv(user, "last_login_precision");
 
-       const struct dict_op_settings *dset = mail_user_get_dict_op_settings(user);
-       trans = dict_transaction_begin(dict, dset);
+       struct dict_op_settings dset = *mail_user_get_dict_op_settings(user);
+       dset.no_slowness_warning = TRUE;
+       trans = dict_transaction_begin(dict, &dset);
        if (precision == NULL || strcmp(precision, "s") == 0)
                dict_set(trans, key_name, dec2str(ioloop_time));
        else if (strcmp(precision, "ms") == 0) {
@@ -138,7 +139,6 @@ static void last_login_mail_user_created(struct mail_user *user)
        } else {
                i_error("last_login_dict: Invalid last_login_precision '%s'", precision);
        }
-       dict_transaction_no_slowness_warning(trans);
        dict_transaction_commit_async(&trans, last_login_dict_commit, user);
 }