dovecot-2.2: login proxy: Use corking when writing data.

dovecot at dovecot.org dovecot at dovecot.org
Thu Oct 24 16:08:29 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/2d3d73d03fe2
changeset: 16880:2d3d73d03fe2
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Oct 24 16:08:23 2013 +0300
description:
login proxy: Use corking when writing data.

diffstat:

 src/login-common/client-common-auth.c |   6 ++++++
 src/login-common/login-proxy.c        |  22 ++++++++++++++++------
 2 files changed, 22 insertions(+), 6 deletions(-)

diffs (82 lines):

diff -r 082ca23fa9f4 -r 2d3d73d03fe2 src/login-common/client-common-auth.c
--- a/src/login-common/client-common-auth.c	Thu Oct 24 14:59:03 2013 +0300
+++ b/src/login-common/client-common-auth.c	Thu Oct 24 16:08:23 2013 +0300
@@ -222,6 +222,7 @@
 static void proxy_input(struct client *client)
 {
 	struct istream *input;
+	struct ostream *output;
 	const char *line;
 	unsigned int duration;
 
@@ -265,10 +266,15 @@
 		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 -r 082ca23fa9f4 -r 2d3d73d03fe2 src/login-common/login-proxy.c
--- a/src/login-common/login-proxy.c	Thu Oct 24 14:59:03 2013 +0300
+++ b/src/login-common/login-proxy.c	Thu Oct 24 16:08:23 2013 +0300
@@ -78,7 +78,7 @@
 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 @@
 	}
 
 	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 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 @@
 	}
 
 	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");


More information about the dovecot-cvs mailing list