dovecot-2.2: lib-imap-client: When server sends BYE before disco...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jun 6 09:47:50 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/55624c42bfb8
changeset: 16465:55624c42bfb8
user: Timo Sirainen <tss at iki.fi>
date: Thu Jun 06 09:47:39 2013 +0300
description:
lib-imap-client: When server sends BYE before disconnection, log it as the reason.
diffstat:
src/lib-imap-client/imapc-connection.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diffs (58 lines):
diff -r cc243b748a1c -r 55624c42bfb8 src/lib-imap-client/imapc-connection.c
--- a/src/lib-imap-client/imapc-connection.c Thu Jun 06 08:57:13 2013 +0300
+++ b/src/lib-imap-client/imapc-connection.c Thu Jun 06 09:47:39 2013 +0300
@@ -92,6 +92,7 @@
struct imapc_client_mailbox *selecting_box, *selected_box;
enum imapc_connection_state state;
+ char *disconnect_reason;
enum imapc_capability capabilities;
char **capabilities_list;
@@ -159,6 +160,8 @@
if (--conn->refcount > 0)
return;
+ i_assert(conn->disconnect_reason == NULL);
+
if (conn->capabilities_list != NULL)
p_strsplit_free(default_pool, conn->capabilities_list);
array_free(&conn->cmd_send_queue);
@@ -299,8 +302,13 @@
case IMAPC_CONNECTION_STATE_DISCONNECTED:
memset(&reply, 0, sizeof(reply));
reply.state = IMAPC_COMMAND_STATE_DISCONNECTED;
- reply.text_without_resp = reply.text_full =
- "Disconnected from server";
+ reply.text_full = "Disconnected from server";
+ if (conn->disconnect_reason != NULL) {
+ reply.text_full = t_strdup_printf("%s: %s",
+ reply.text_full, conn->disconnect_reason);
+ i_free_and_null(conn->disconnect_reason);
+ }
+ reply.text_without_resp = reply.text_full;
imapc_login_callback(conn, &reply);
conn->idling = FALSE;
@@ -899,6 +907,9 @@
value = imap_args_to_str(imap_args);
if (imapc_connection_parse_capability(conn, value) < 0)
return -1;
+ } else if (strcasecmp(name, "BYE") == 0) {
+ i_free(conn->disconnect_reason);
+ conn->disconnect_reason = i_strdup(imap_args_to_str(imap_args));
}
reply.name = name;
@@ -1120,7 +1131,10 @@
if (ret < 0) {
/* disconnected */
- if (conn->ssl_iostream == NULL) {
+ if (conn->disconnect_reason != NULL) {
+ i_error("imapc(%s): Server disconnected with message: %s",
+ conn->name, conn->disconnect_reason);
+ } else if (conn->ssl_iostream == NULL) {
i_error("imapc(%s): Server disconnected unexpectedly",
conn->name);
} else {
More information about the dovecot-cvs
mailing list