Mercurial > dovecot > core-2.2
changeset 19815:6cbcdcbd9ad7
doveadm-http: Close client input correctly
author | Aki Tuomi <aki.tuomi@dovecot.fi> |
---|---|
date | Mon, 22 Feb 2016 20:03:44 +0200 |
parents | 79ca5c365eac |
children | e2f9c117aef7 |
files | src/doveadm/client-connection-http.c src/doveadm/client-connection.c |
diffstat | 2 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/doveadm/client-connection-http.c Mon Feb 22 20:00:13 2016 +0200 +++ b/src/doveadm/client-connection-http.c Mon Feb 22 20:03:44 2016 +0200 @@ -132,6 +132,9 @@ (void)json_parser_deinit(&conn->json_parser, &error); // we've already failed, ignore error } + if (conn->client.output != NULL) + o_stream_set_no_error_handling(conn->client.output, TRUE); + http_server_request_unref(&(conn->http_server_request)); http_server_switch_ioloop(doveadm_http_server); http_server_connection_unref(&(conn->http_client)); @@ -462,6 +465,9 @@ if (!conn->client.input->eof && rc == 0) return; + io_remove(&conn->client.io); + conn->client.io = NULL; + if (rc == -2 || (rc == 1 && conn->json_state != JSON_STATE_DONE)) { /* this will happen if the parser above runs into unexpected element, but JSON is OK */ http_server_request_fail_close(conn->http_server_request, 400, "Unexpected element in input"); @@ -488,11 +494,6 @@ conn->json_parser = NULL; - io_remove(&conn->client.io); - conn->client.io = NULL; - i_stream_unref(&conn->client.input); - conn->client.input = NULL; - if (conn->client.output != NULL) o_stream_nsend_str(conn->client.output,"]");
--- a/src/doveadm/client-connection.c Mon Feb 22 20:00:13 2016 +0200 +++ b/src/doveadm/client-connection.c Mon Feb 22 20:03:44 2016 +0200 @@ -570,8 +570,11 @@ o_stream_destroy(&conn->output); if (conn->io != NULL) { + io_remove(&conn->io); + } + + if (conn->input != NULL) { i_stream_destroy(&conn->input); - io_remove(&conn->io); } if (conn->fd > 0 && close(conn->fd) < 0)