From e9c0bb1f4d0fbbdb34d11df82e30f58ba2cf3410 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 19 Oct 2014 11:24:12 -0700 Subject: [PATCH] imap, pop3, lmtp: If client gets disconnected due to iostream error, log the full error. --- src/imap/imap-client.c | 8 ++++++-- src/lmtp/client.c | 9 ++++++--- src/pop3/pop3-client.c | 9 ++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index 613c11783a..f35a02ed3a 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -223,8 +223,12 @@ static const char *client_get_disconnect_reason(struct client *client) errno = client->input->stream_errno != 0 ? client->input->stream_errno : client->output->stream_errno; - return errno == 0 || errno == EPIPE ? "Connection closed" : - t_strdup_printf("Connection closed: %m"); + if (errno == 0 || errno == EPIPE) + return "Connection closed"; + return t_strdup_printf("Connection closed: %s", + client->input->stream_errno != 0 ? + i_stream_get_error(client->input) : + o_stream_get_error(client->output)); } void client_destroy(struct client *client, const char *reason) diff --git a/src/lmtp/client.c b/src/lmtp/client.c index 7b336641de..8adae4b351 100644 --- a/src/lmtp/client.c +++ b/src/lmtp/client.c @@ -293,10 +293,13 @@ static const char *client_get_disconnect_reason(struct client *client) errno = client->input->stream_errno != 0 ? client->input->stream_errno : client->output->stream_errno; - return errno == 0 || errno == EPIPE ? "Connection closed" : - t_strdup_printf("Connection closed: %m"); + if (errno == 0 || errno == EPIPE) + return "Connection closed"; + return t_strdup_printf("Connection closed: %s", + client->input->stream_errno != 0 ? + i_stream_get_error(client->input) : + o_stream_get_error(client->output)); } - void client_disconnect(struct client *client, const char *prefix, const char *reason) { diff --git a/src/pop3/pop3-client.c b/src/pop3/pop3-client.c index 096bf1f1a1..2696ac90ae 100644 --- a/src/pop3/pop3-client.c +++ b/src/pop3/pop3-client.c @@ -557,10 +557,13 @@ static const char *client_get_disconnect_reason(struct client *client) errno = client->input->stream_errno != 0 ? client->input->stream_errno : client->output->stream_errno; - return errno == 0 || errno == EPIPE ? "Connection closed" : - t_strdup_printf("Connection closed: %m"); + if (errno == 0 || errno == EPIPE) + return "Connection closed"; + return t_strdup_printf("Connection closed: %s", + client->input->stream_errno != 0 ? + i_stream_get_error(client->input) : + o_stream_get_error(client->output)); } - void client_destroy(struct client *client, const char *reason) { client->v.destroy(client, reason); -- 2.47.3