changeset 13406:991ce1aed5f7

imapc: Error logging fix when SSL handshake fails.
author Timo Sirainen <tss@iki.fi>
date Tue, 06 Sep 2011 16:42:19 +0300
parents e40d6b5ef97e
children 7b115033405d
files src/lib-storage/index/imapc/imapc-connection.c
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-connection.c	Tue Sep 06 16:33:09 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-connection.c	Tue Sep 06 16:42:19 2011 +0300
@@ -99,6 +99,7 @@
 	unsigned int idling:1;
 	unsigned int idle_stopping:1;
 	unsigned int idle_plus_waiting:1;
+	unsigned int handshake_failed:1;
 };
 
 static int imapc_connection_output(struct imapc_connection *conn);
@@ -941,6 +942,7 @@
 
 static void imapc_connection_input(struct imapc_connection *conn)
 {
+	const char *errstr;
 	ssize_t ret = 0;
 
 	/* we need to read as much as we can with SSL streams to avoid
@@ -953,9 +955,10 @@
 		if (conn->ssl_iostream == NULL) {
 			i_error("imapc(%s): Server disconnected unexpectedly",
 				conn->name);
-		} else {
-			i_error("imapc(%s): Server disconnected: %s", conn->name,
-				ssl_iostream_get_last_error(conn->ssl_iostream));
+		} else if (!conn->handshake_failed) {
+			errstr = ssl_iostream_get_last_error(conn->ssl_iostream);
+			i_error("imapc(%s): Server disconnected: %s",
+				conn->name, errstr != NULL ? errstr : "");
 		}
 		imapc_connection_disconnect(conn);
 		return;
@@ -985,6 +988,7 @@
 		}
 		return 0;
 	}
+	conn->handshake_failed = TRUE;
 	i_stream_close(conn->input);
 	return -1;
 }