]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict-client: Don't log slow background async commit/iteration replies.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 1 Jul 2016 13:34:26 +0000 (16:34 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 1 Jul 2016 13:34:26 +0000 (16:34 +0300)
If a caller has already finished iteration, or does async commit without a
callback, it means that it started the query without caring when it
finishes. The caller may already have been doing blocking work while
waiting for the dict reply. We don't want to log a warning, because it
could be completely wrong.

src/lib-dict/dict-client.c

index 5cfc7809dc14f131e9d9291b33c1fd7f33a101b5..9d9eff414420821d2b377971080f42c64273033c 100644 (file)
@@ -36,6 +36,7 @@ struct client_dict_cmd {
        bool retry_errors;
        bool no_replies;
        bool unfinished;
+       bool background;
 
        void (*callback)(struct client_dict_cmd *cmd,
                         const char *line, const char *error);
@@ -361,7 +362,8 @@ static int dict_conn_input_line(struct connection *_conn, const char *line)
                /* more lines needed for this command */
                return 1;
        }
-       diff = timeval_diff_msecs(&ioloop_timeval, &cmds[0]->start_time);
+       diff = cmds[0]->background ? 0 :
+               timeval_diff_msecs(&ioloop_timeval, &cmds[0]->start_time);
        if (diff >= DICT_CLIENT_REQUEST_WARN_TIMEOUT_MSECS) {
                i_warning("read(%s): dict lookup took %u.%03u seconds: %s",
                          dict->conn.conn.name, diff/1000, diff % 1000,
@@ -712,6 +714,9 @@ client_dict_iter_async_callback(struct client_dict_cmd *cmd, const char *line,
        struct client_dict_iter_result *result;
        const char *key = NULL, *value = NULL;
 
+       if (ctx->deinit)
+               cmd->background = TRUE;
+
        if (error != NULL) {
                /* failed */
        } else switch (*line) {
@@ -929,6 +934,8 @@ client_dict_transaction_commit(struct dict_transaction_context *_ctx,
                } else {
                        cmd->api_callback.commit = commit_sync_callback;
                        cmd->api_callback.context = &ret;
+                       if (async)
+                               cmd->background = TRUE;
                }
                if (client_dict_cmd_send(dict, &cmd, NULL)) {
                        if (!async)