changeset 2712:c710572d7075 HEAD

Buffer more in memory before sending RETR replies.
author Timo Sirainen <tss@iki.fi>
date Sat, 09 Oct 2004 00:21:11 +0300
parents d2e899bb6f5b
children e11ac6ab7470
files src/pop3/client.c src/pop3/commands.c
diffstat 2 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/pop3/client.c	Fri Oct 08 23:25:00 2004 +0300
+++ b/src/pop3/client.c	Sat Oct 09 00:21:11 2004 +0300
@@ -404,8 +404,10 @@
 
 	client->last_output = ioloop_time;
 
+	o_stream_cork(client->output);
 	if (client->cmd != NULL)
 		client->cmd(client);
+	o_stream_uncork(client->output);
 
 	if (o_stream_get_buffer_used_size(client->output) <
 	    OUTBUF_THROTTLE_SIZE/2 && client->io == NULL &&
--- a/src/pop3/commands.c	Fri Oct 08 23:25:00 2004 +0300
+++ b/src/pop3/commands.c	Sat Oct 09 00:21:11 2004 +0300
@@ -227,8 +227,7 @@
 	const unsigned char *data;
 	unsigned char add;
 	size_t i, size;
-
-	o_stream_uncork(client->output);
+	int ret;
 
 	while ((ctx->body_lines > 0 || !ctx->in_body) &&
 	       i_stream_read_data(ctx->stream, &data, &size, 0) > 0) {
@@ -281,12 +280,13 @@
 			i_stream_skip(ctx->stream, i);
 		}
 
-		if (o_stream_get_buffer_used_size(client->output) > 0) {
-			if (client->output->closed)
+		if (o_stream_get_buffer_used_size(client->output) >= 4096) {
+			if ((ret = o_stream_flush(client->output)) < 0)
 				break;
-
-			/* continue later */
-			return;
+			if (ret == 0) {
+				/* continue later */
+				return;
+			}
 		}
 
 		if (add != '\0') {