dovecot-2.2: lib: connection_disconnect_reason() now returns the...

dovecot at dovecot.org dovecot at dovecot.org
Mon Aug 24 09:05:48 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/984ce015e9d0
changeset: 18988:984ce015e9d0
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Aug 24 12:04:55 2015 +0300
description:
lib: connection_disconnect_reason() now returns the full iostream error string.

diffstat:

 src/lib/connection.c |  20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diffs (33 lines):

diff -r 9f815e781beb -r 984ce015e9d0 src/lib/connection.c
--- a/src/lib/connection.c	Thu Aug 20 16:04:48 2015 +0300
+++ b/src/lib/connection.c	Mon Aug 24 12:04:55 2015 +0300
@@ -358,15 +358,23 @@
 
 const char *connection_disconnect_reason(struct connection *conn)
 {
-	if (conn->input != NULL && conn->input->stream_errno != 0)
+	const char *errstr;
+
+	if (conn->input != NULL && conn->input->stream_errno != 0) {
 		errno = conn->input->stream_errno;
-	else if (conn->output != NULL && conn->output->stream_errno != 0)
+		errstr = i_stream_get_error(conn->input);
+	} else if (conn->output != NULL && conn->output->stream_errno != 0) {
 		errno = conn->output->stream_errno;
+		errstr = o_stream_get_error(conn->output);
+	} else {
+		errno = 0;
+		errstr = "";
+	}
+
+	if (errno == 0 || errno == EPIPE)
+		return "Connection closed";
 	else
-		errno = 0;
-
-	return errno == 0 || errno == EPIPE ? "Connection closed" :
-		t_strdup_printf("Connection closed: %m");
+		return t_strdup_printf("Connection closed: %s", errstr);
 }
 
 void connection_switch_ioloop(struct connection *conn)


More information about the dovecot-cvs mailing list