changeset 12265:f3aa8be626fa

imap, pop3: Cork TCP connection before trying to flush output in output callback.
author Timo Sirainen <tss@iki.fi>
date Thu, 14 Oct 2010 16:58:57 +0100
parents a3e40c6b14fe
children c38f630dae09
files src/imap/imap-client.c src/pop3/pop3-client.c
diffstat 2 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/imap-client.c	Thu Oct 14 16:53:04 2010 +0100
+++ b/src/imap/imap-client.c	Thu Oct 14 16:58:57 2010 +0100
@@ -847,6 +847,7 @@
 	if (client->to_idle_output != NULL)
 		timeout_reset(client->to_idle_output);
 
+	o_stream_cork(client->output);
 	if ((ret = o_stream_flush(client->output)) < 0) {
 		client_destroy(client, NULL);
 		return 1;
@@ -856,7 +857,6 @@
 	for (cmd = client->command_queue; cmd != NULL; cmd = cmd->next)
 		cmd->temp_executed = FALSE;
 
-	o_stream_cork(client->output);
 	if (client->output_lock != NULL) {
 		client->output_lock->temp_executed = TRUE;
 		client_output_cmd(client->output_lock);
--- a/src/pop3/pop3-client.c	Thu Oct 14 16:53:04 2010 +0100
+++ b/src/pop3/pop3-client.c	Thu Oct 14 16:58:57 2010 +0100
@@ -641,6 +641,7 @@
 
 static int client_output(struct client *client)
 {
+	o_stream_cork(client->output);
 	if (o_stream_flush(client->output) < 0) {
 		client_destroy(client, NULL);
 		return 1;
@@ -651,11 +652,8 @@
 	if (client->to_commit != NULL)
 		timeout_reset(client->to_commit);
 
-	if (client->cmd != NULL) {
-		o_stream_cork(client->output);
+	if (client->cmd != NULL)
 		client->cmd(client);
-		o_stream_uncork(client->output);
-	}
 
 	if (client->cmd == NULL) {
 		if (o_stream_get_buffer_used_size(client->output) <
@@ -668,6 +666,7 @@
 			client_input(client);
 	}
 
+	o_stream_uncork(client->output);
 	return client->cmd == NULL;
 }