dovecot-2.1: lib-ssl-iostream: Some tweaks to BIO handling.

dovecot at dovecot.org dovecot at dovecot.org
Wed Sep 7 16:10:25 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/9380133c8531
changeset: 13425:9380133c8531
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Sep 07 16:10:16 2011 +0300
description:
lib-ssl-iostream: Some tweaks to BIO handling.

diffstat:

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

diffs (52 lines):

diff -r f7de547a54d5 -r 9380133c8531 src/lib-ssl-iostream/iostream-openssl.c
--- a/src/lib-ssl-iostream/iostream-openssl.c	Wed Sep 07 15:46:43 2011 +0300
+++ b/src/lib-ssl-iostream/iostream-openssl.c	Wed Sep 07 16:10:16 2011 +0300
@@ -322,6 +322,17 @@
 		i_stream_skip(ssl_io->plain_input, size);
 		bytes_read = TRUE;
 	}
+	if (bytes == 0 && !bytes_read && ssl_io->want_read) {
+		/* shouldn't happen */
+		i_panic("SSL BIO buffer size too small");
+	}
+	if (bytes_read) {
+		if (ssl_io->ostream_flush_waiting_input) {
+			ssl_io->ostream_flush_waiting_input = FALSE;
+			o_stream_set_flush_pending(ssl_io->plain_output, TRUE);
+		}
+		ssl_io->want_read = FALSE;
+	}
 	return bytes_read;
 }
 
@@ -330,14 +341,8 @@
 	bool ret;
 
 	ret = ssl_iostream_bio_output(ssl_io);
-	if (ssl_iostream_bio_input(ssl_io)) {
-		if (ssl_io->ostream_flush_waiting_input) {
-			ssl_io->ostream_flush_waiting_input = FALSE;
-			o_stream_set_flush_pending(ssl_io->plain_output, TRUE);
-		}
-		ssl_io->want_read = FALSE;
+	if (ssl_iostream_bio_input(ssl_io))
 		ret = TRUE;
-	}
 	return ret;
 }
 
@@ -374,11 +379,9 @@
 		}
 		return 1;
 	case SSL_ERROR_WANT_READ:
-		if (!ssl_iostream_bio_sync(ssl_io)) {
-			ssl_io->want_read = TRUE;
-			return 0;
-		}
-		return 1;
+		ssl_io->want_read = TRUE;
+		(void)ssl_iostream_bio_sync(ssl_io);
+		return ssl_io->want_read ? 0 : 1;
 	case SSL_ERROR_SYSCALL:
 		/* eat up the error queue */
 		if (ERR_peek_error() != 0) {


More information about the dovecot-cvs mailing list