Mercurial > dovecot > core-2.2
changeset 20547:879b2a660a95
dict-client: Don't keep a request timeout when there are only background commands.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 25 Jul 2016 17:41:36 -0400 |
parents | e8b44e9197e2 |
children | 5f6962a5be0f |
files | src/lib-dict/dict-client.c |
diffstat | 1 files changed, 19 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-dict/dict-client.c Mon Jul 25 17:32:11 2016 -0400 +++ b/src/lib-dict/dict-client.c Mon Jul 25 17:41:36 2016 -0400 @@ -272,7 +272,7 @@ *error_r = error; return FALSE; } else { - if (dict->to_requests == NULL) { + if (dict->to_requests == NULL && !cmd->background) { dict->to_requests = timeout_add(DICT_CLIENT_REQUEST_TIMEOUT_MSECS, client_dict_input_timeout, dict); @@ -355,6 +355,21 @@ } } +static void client_dict_cmd_backgrounded(struct client_dict *dict) +{ + struct client_dict_cmd *const *cmdp; + + if (dict->to_requests == NULL) + return; + + array_foreach(&dict->cmds, cmdp) { + if (!(*cmdp)->background) + return; + } + /* we only have background-commands. remove the request timeout. */ + timeout_remove(&dict->to_requests); +} + static int dict_conn_input_line(struct connection *_conn, const char *line) { struct dict_connection *conn = (struct dict_connection *)_conn; @@ -799,8 +814,10 @@ struct client_dict_iter_result *result; const char *key = NULL, *value = NULL; - if (ctx->deinit) + if (ctx->deinit) { cmd->background = TRUE; + client_dict_cmd_backgrounded(dict); + } if (error != NULL) { /* failed */