]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict-client: Don't keep a request timeout when there are only background commands.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 25 Jul 2016 21:41:36 +0000 (17:41 -0400)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 1 Aug 2016 22:03:58 +0000 (01:03 +0300)
src/lib-dict/dict-client.c

index 19d3ce2eaca9dfcd011c4df919b2dbdcaae64434..045adf6f9469df0c6d4a214bb66de7eb2695dbca 100644 (file)
@@ -272,7 +272,7 @@ client_dict_cmd_send(struct client_dict *dict, struct client_dict_cmd **_cmd,
                        *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_add_timeout(struct client_dict *dict)
        }
 }
 
+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;
@@ -798,8 +813,10 @@ 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)
+       if (ctx->deinit) {
                cmd->background = TRUE;
+               client_dict_cmd_backgrounded(dict);
+       }
 
        if (error != NULL) {
                /* failed */