dovecot-2.2: doveadm: If server connection gets disconnected, lo...

dovecot at dovecot.org dovecot at dovecot.org
Tue Aug 6 18:28:51 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/c5c3eba6ae14
changeset: 16674:c5c3eba6ae14
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Aug 06 18:28:31 2013 +0300
description:
doveadm: If server connection gets disconnected, log the reason.

diffstat:

 src/doveadm/server-connection.c |  18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diffs (43 lines):

diff -r 64464646c020 -r c5c3eba6ae14 src/doveadm/server-connection.c
--- a/src/doveadm/server-connection.c	Tue Aug 06 17:16:58 2013 +0300
+++ b/src/doveadm/server-connection.c	Tue Aug 06 18:28:31 2013 +0300
@@ -199,6 +199,19 @@
 	return 0;
 }
 
+static void server_log_disconnect_error(struct server_connection *conn)
+{
+	const char *error;
+
+	error = conn->ssl_iostream == NULL ? NULL :
+		ssl_iostream_get_last_error(conn->ssl_iostream);
+	if (error == NULL) {
+		error = conn->input->stream_errno == 0 ? "EOF" :
+			strerror(conn->input->stream_errno);
+	}
+	i_error("doveadm server disconnected before handshake: %s", error);
+}
+
 static void server_connection_input(struct server_connection *conn)
 {
 	const unsigned char *data;
@@ -208,8 +221,10 @@
 
 	if (!conn->handshaked) {
 		if ((line = i_stream_read_next_line(conn->input)) == NULL) {
-			if (conn->input->eof || conn->input->stream_errno != 0)
+			if (conn->input->eof || conn->input->stream_errno != 0) {
+				server_log_disconnect_error(conn);
 				server_connection_destroy(&conn);
+			}
 			return;
 		}
 
@@ -232,6 +247,7 @@
 
 	if (i_stream_read(conn->input) < 0) {
 		/* disconnected */
+		server_log_disconnect_error(conn);
 		server_connection_destroy(&conn);
 		return;
 	}


More information about the dovecot-cvs mailing list