]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict: Fix deinitializing dict iteration if client disconnects
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 14 May 2020 19:52:34 +0000 (22:52 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 20 May 2020 08:56:20 +0000 (08:56 +0000)
If the client's ostream was full at the disconnection time, the iteration
wasn't aborted. Instead, the connection was kept forever and its input
callback was kept being called rapidly, causing 100% CPU usage.

src/dict/dict-commands.c

index 85d57e9ddf965e6b7d3e124eb4aa3c81e7001ac0..003a15e57529bbd11eadc18c3a70c51ace73540c 100644 (file)
@@ -264,13 +264,17 @@ cmd_iterate_flush_finish(struct dict_connection_cmd *cmd, string_t *str)
 
 static int cmd_iterate_flush(struct dict_connection_cmd *cmd)
 {
-       string_t *str;
+       string_t *str = t_str_new(256);
        const char *key, *value;
 
+       if (cmd->conn->destroyed) {
+               cmd_iterate_flush_finish(cmd, str);
+               return 1;
+       }
+
        if (!dict_connection_flush_if_full(cmd->conn))
                return 0;
 
-       str = t_str_new(256);
        while (dict_iterate(cmd->iter, &key, &value)) {
                cmd->rows++;
                str_truncate(str, 0);