dovecot-2.2: lmtp: Create all proxy DATA streams before reading ...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jun 19 12:52:00 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/119adb7d2479
changeset: 17513:119adb7d2479
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jun 19 15:50:40 2014 +0300
description:
lmtp: Create all proxy DATA streams before reading from them.
I'm not sure if this actually fixes anything or not, but it's still safer
to do it this way.

diffstat:

 src/lmtp/lmtp-proxy.c |  16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diffs (40 lines):

diff -r 467a4d19f873 -r 119adb7d2479 src/lmtp/lmtp-proxy.c
--- a/src/lmtp/lmtp-proxy.c	Thu Jun 19 15:15:24 2014 +0300
+++ b/src/lmtp/lmtp-proxy.c	Thu Jun 19 15:50:40 2014 +0300
@@ -296,12 +296,14 @@
 	struct lmtp_proxy_connection *const *conns;
 
 	i_assert(data_input->seekable);
+	i_assert(proxy->data_input == NULL);
 
 	proxy->finish_callback = callback;
 	proxy->finish_context = context;
 	proxy->data_input = data_input;
 	i_stream_ref(proxy->data_input);
 
+	/* create the data_input streams first */
 	array_foreach(&proxy->connections, conns) {
 		struct lmtp_proxy_connection *conn = *conns;
 
@@ -312,10 +314,18 @@
 
 		conn->to = timeout_add(proxy->max_timeout_msecs,
 				       lmtp_proxy_conn_timeout, conn);
+		conn->data_input = i_stream_create_limit(data_input, (uoff_t)-1);
+	}
+	/* now that all the streams are created, start reading them
+	   (reading them earlier could have caused the data_input parent's
+	   offset to change) */
+	array_foreach(&proxy->connections, conns) {
+		struct lmtp_proxy_connection *conn = *conns;
 
-		conn->data_input = i_stream_create_limit(data_input, (uoff_t)-1);
-		lmtp_client_send(conn->client, conn->data_input);
-		lmtp_client_send_more(conn->client);
+		if (conn->data_input != NULL) {
+			lmtp_client_send(conn->client, conn->data_input);
+			lmtp_client_send_more(conn->client);
+		}
 	}
 	/* finish if all of the connections have already failed */
 	lmtp_proxy_try_finish(proxy);


More information about the dovecot-cvs mailing list