changeset 18734:191eaf662c21

lib: Cork connection output while handling input
author Timo Sirainen <tss@iki.fi>
date Thu, 21 May 2015 08:38:56 -0400
parents 5b902db0cabc
children 5aae57dc5ad6
files src/lib/connection.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/connection.c	Thu May 21 06:35:59 2015 -0400
+++ b/src/lib/connection.c	Thu May 21 08:38:56 2015 -0400
@@ -27,6 +27,7 @@
 {
 	const char *line;
 	struct istream *input;
+	struct ostream *output;
 	int ret = 0;
 
 	switch (connection_input_read(conn)) {
@@ -40,7 +41,12 @@
 	}
 
 	input = conn->input;
+	output = conn->output;
 	i_stream_ref(input);
+	if (output != NULL) {
+		o_stream_ref(output);
+		o_stream_cork(output);
+	}
 	while (!input->closed && (line = i_stream_next_line(input)) != NULL) {
 		T_BEGIN {
 			ret = conn->list->v.input_line(conn, line);
@@ -48,6 +54,10 @@
 		if (ret <= 0)
 			break;
 	}
+	if (output != NULL) {
+		o_stream_uncork(output);
+		o_stream_unref(&output);
+	}
 	if (ret < 0 && !input->closed) {
 		conn->disconnect_reason = CONNECTION_DISCONNECT_DEINIT;
 		conn->list->v.destroy(conn);