From: Timo Sirainen Date: Thu, 14 May 2020 19:52:34 +0000 (+0300) Subject: dict: Fix deinitializing dict iteration if client disconnects X-Git-Tag: 2.3.11.2~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a7061d8f8e43388ef3ca584b04acb9b4c2fc7148;p=thirdparty%2Fdovecot%2Fcore.git dict: Fix deinitializing dict iteration if client disconnects 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. --- diff --git a/src/dict/dict-commands.c b/src/dict/dict-commands.c index 85d57e9ddf..003a15e575 100644 --- a/src/dict/dict-commands.c +++ b/src/dict/dict-commands.c @@ -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);