From: Timo Sirainen Date: Thu, 24 Oct 2013 13:08:23 +0000 (+0300) Subject: login proxy: Use corking when writing data. X-Git-Tag: 2.2.7~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e911b23f3e05308df9b98b1a3fdaf72e4302d8fd;p=thirdparty%2Fdovecot%2Fcore.git login proxy: Use corking when writing data. --- diff --git a/src/login-common/client-common-auth.c b/src/login-common/client-common-auth.c index 8a5d3cab65..9400323d8d 100644 --- a/src/login-common/client-common-auth.c +++ b/src/login-common/client-common-auth.c @@ -222,6 +222,7 @@ static const char *get_disconnect_reason(struct istream *input) static void proxy_input(struct client *client) { struct istream *input; + struct ostream *output; const char *line; unsigned int duration; @@ -265,10 +266,15 @@ static void proxy_input(struct client *client) return; } + output = client->output; + o_stream_ref(output); + o_stream_cork(output); while ((line = i_stream_next_line(input)) != NULL) { if (client->v.proxy_parse_line(client, line) != 0) break; } + o_stream_uncork(output); + o_stream_unref(&output); } static int proxy_start(struct client *client, diff --git a/src/login-common/login-proxy.c b/src/login-common/login-proxy.c index d2833e2784..00a268fd5b 100644 --- a/src/login-common/login-proxy.c +++ b/src/login-common/login-proxy.c @@ -78,7 +78,7 @@ static void login_proxy_free_errno(struct login_proxy **proxy, static void server_input(struct login_proxy *proxy) { unsigned char buf[OUTBUF_THRESHOLD]; - ssize_t ret; + ssize_t ret, ret2; proxy->last_io = ioloop_time; if (o_stream_get_buffer_used_size(proxy->client_output) > @@ -90,9 +90,14 @@ static void server_input(struct login_proxy *proxy) } ret = net_receive(proxy->server_fd, buf, sizeof(buf)); - if (ret < 0) + if (ret < 0) { login_proxy_free_errno(&proxy, errno, "server"); - else if (o_stream_send(proxy->client_output, buf, ret) != ret) { + return; + } + o_stream_cork(proxy->client_output); + ret2 = o_stream_send(proxy->client_output, buf, ret); + o_stream_uncork(proxy->client_output); + if (ret2 != ret) { login_proxy_free_errno(&proxy, proxy->client_output->stream_errno, "client"); @@ -102,7 +107,7 @@ static void server_input(struct login_proxy *proxy) static void proxy_client_input(struct login_proxy *proxy) { unsigned char buf[OUTBUF_THRESHOLD]; - ssize_t ret; + ssize_t ret, ret2; proxy->last_io = ioloop_time; if (o_stream_get_buffer_used_size(proxy->server_output) > @@ -114,9 +119,14 @@ static void proxy_client_input(struct login_proxy *proxy) } ret = net_receive(proxy->client_fd, buf, sizeof(buf)); - if (ret < 0) + if (ret < 0) { login_proxy_free_errno(&proxy, errno, "client"); - else if (o_stream_send(proxy->server_output, buf, ret) != ret) { + return; + } + o_stream_cork(proxy->client_output); + ret2 = o_stream_send(proxy->server_output, buf, ret); + o_stream_uncork(proxy->server_output); + if (ret2 != ret) { login_proxy_free_errno(&proxy, proxy->server_output->stream_errno, "server");