]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict: Moved iterate's corking to more correct location.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 21 Nov 2016 16:52:25 +0000 (18:52 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 21 Nov 2016 20:44:25 +0000 (22:44 +0200)
Commands' input handling already corks ostream in connection.c.

src/dict/dict-commands.c
src/dict/dict-connection.c

index e5dc691ab9d36cbb7fd935647b80e93534a4c2f6..b39a0200a6672c45e5f8a3ffaab9220d30673378 100644 (file)
@@ -157,7 +157,6 @@ static int cmd_iterate_flush(struct dict_connection_cmd *cmd)
        const char *key, *value;
 
        str = t_str_new(256);
-       o_stream_cork(cmd->conn->output);
        while (dict_iterate(cmd->iter, &key, &value)) {
                str_truncate(str, 0);
                str_append_c(str, DICT_PROTOCOL_REPLY_OK);
@@ -173,7 +172,6 @@ static int cmd_iterate_flush(struct dict_connection_cmd *cmd)
                        if (o_stream_flush(cmd->conn->output) <= 0) {
                                /* continue later when there's more space
                                   in output buffer */
-                               o_stream_uncork(cmd->conn->output);
                                o_stream_set_flush_pending(cmd->conn->output, TRUE);
                                return 0;
                        }
@@ -190,7 +188,6 @@ static int cmd_iterate_flush(struct dict_connection_cmd *cmd)
                str_append_c(str, DICT_PROTOCOL_REPLY_FAIL);
        dict_cmd_reply_handle_timings(cmd, str, cmd_stats.iterations);
        str_append_c(str, '\n');
-       o_stream_uncork(cmd->conn->output);
 
        cmd->reply = i_strdup(str_c(str));
        return 1;
@@ -199,8 +196,13 @@ static int cmd_iterate_flush(struct dict_connection_cmd *cmd)
 static void cmd_iterate_callback(void *context)
 {
        struct dict_connection_cmd *cmd = context;
+       struct dict_connection *conn = cmd->conn;
 
+       dict_connection_ref(conn);
+       o_stream_cork(conn->output);
        dict_connection_cmd_output_more(cmd);
+       o_stream_uncork(conn->output);
+       dict_connection_unref_safe(conn);
 }
 
 static int cmd_iterate(struct dict_connection_cmd *cmd, const char *line)
index 318b0741a616045bce28f8027c3299657cc7775c..518222f8bf40d1b103c8d3ca37ec52678ded3856 100644 (file)
@@ -179,14 +179,17 @@ void dict_connection_continue_input(struct dict_connection *conn)
 
 static int dict_connection_output(struct dict_connection *conn)
 {
+       struct ostream *output = conn->output;
        int ret;
 
+       o_stream_cork(output);
        if ((ret = o_stream_flush(conn->output)) < 0) {
                dict_connection_destroy(conn);
-               return 1;
-       }
-       if (ret > 0)
+               ret = 1;
+       } else if (ret > 0) {
                dict_connection_cmds_output_more(conn);
+       }
+       o_stream_uncork(output);
        return ret;
 }