dovecot-2.1: lib-ssl-iostream: Fixed ostream to preserve/use flu...

dovecot at dovecot.org dovecot at dovecot.org
Wed Sep 7 11:19:20 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/de7f3810589a
changeset: 13420:de7f3810589a
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Sep 07 11:18:15 2011 +0300
description:
lib-ssl-iostream: Fixed ostream to preserve/use flush callback correctly.

diffstat:

 src/lib-ssl-iostream/ostream-openssl.c |  12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diffs (36 lines):

diff -r 31471ce338ab -r de7f3810589a src/lib-ssl-iostream/ostream-openssl.c
--- a/src/lib-ssl-iostream/ostream-openssl.c	Wed Sep 07 11:03:33 2011 +0300
+++ b/src/lib-ssl-iostream/ostream-openssl.c	Wed Sep 07 11:18:15 2011 +0300
@@ -189,6 +189,7 @@
 
 static int plain_flush_callback(struct ssl_ostream *sstream)
 {
+	struct ostream *ostream = &sstream->ostream.ostream;
 	int ret, ret2;
 
 	/* try to actually flush the pending data */
@@ -196,7 +197,14 @@
 		return -1;
 
 	/* we may be able to copy more data, try it */
-	ret2 = o_stream_flush(&sstream->ostream.ostream);
+	o_stream_ref(ostream);
+	if (sstream->ostream.callback != NULL)
+		ret2 = sstream->ostream.callback(sstream->ostream.context);
+	else
+		ret2 = o_stream_flush(&sstream->ostream.ostream);
+	if (ret2 == 0)
+		o_stream_set_flush_pending(sstream->ssl_io->plain_output, TRUE);
+	o_stream_unref(&ostream);
 	if (ret2 < 0)
 		return -1;
 	return ret > 0 && ret2 > 0 ? 1 : 0;
@@ -218,6 +226,8 @@
 	sstream->ostream.flush = o_stream_ssl_flush;
 	sstream->ostream.switch_ioloop = o_stream_ssl_switch_ioloop;
 
+	sstream->ostream.callback = ssl_io->plain_output->real_stream->callback;
+	sstream->ostream.context = ssl_io->plain_output->real_stream->context;
 	o_stream_set_flush_callback(ssl_io->plain_output,
 				    plain_flush_callback, sstream);
 


More information about the dovecot-cvs mailing list