From: Timo Sirainen Date: Thu, 24 Apr 2008 12:48:01 +0000 (+0300) Subject: If remote disconnects, log "Connection closed: reason" just like IMAP does. X-Git-Tag: 1.1.rc5~49 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b854763fc40736ff47012e2581a5c2319e1b0433;p=thirdparty%2Fdovecot%2Fcore.git If remote disconnects, log "Connection closed: reason" just like IMAP does. --HG-- branch : HEAD --- diff --git a/src/pop3/client.c b/src/pop3/client.c index f82f4498ae..b2724f8ada 100644 --- a/src/pop3/client.c +++ b/src/pop3/client.c @@ -239,11 +239,20 @@ static const char *client_stats(struct client *client) return str_c(str); } +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"); +} + void client_destroy(struct client *client, const char *reason) { if (!client->disconnected) { if (reason == NULL) - reason = "Disconnected"; + reason = client_get_disconnect_reason(client); i_info("%s %s", reason, client_stats(client)); }