changeset 12622:31eb7db0c4b9

imapc: Avoid hanging with SSL
author Timo Sirainen <tss@iki.fi>
date Mon, 31 Jan 2011 19:05:18 +0200
parents 4244c828b59d
children dab0e52eb294
files src/lib-storage/index/imapc/imapc-connection.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-connection.c	Mon Jan 31 19:01:58 2011 +0200
+++ b/src/lib-storage/index/imapc/imapc-connection.c	Mon Jan 31 19:05:18 2011 +0200
@@ -852,9 +852,12 @@
 {
 	ssize_t ret;
 
-	if ((ret = i_stream_read(conn->input)) > 0)
+	/* we need to read as much as we can with SSL streams to avoid
+	   hanging */
+	while (conn->input != NULL && (ret = i_stream_read(conn->input)) > 0)
 		imapc_connection_input_pending(conn);
-	else if (ret < 0) {
+
+	if (ret < 0) {
 		/* disconnected */
 		if (conn->ssl_iostream == NULL) {
 			i_error("imapc(%s): Server disconnected unexpectedly",