From d89559a7b2a913f5181d6e886f335561dc6c278d Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Mon, 6 Feb 2017 15:36:50 +0000 Subject: [PATCH] Try (once) to reconnect after an IMAP failure (#366) * Try (once) to reconnect after an IMAP failure Closes #346 * Keep recovering state in IMAP_DATA instead of in a static local variable Closes #346 --- imap/command.c | 10 ++++++++-- imap/imap_private.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/imap/command.c b/imap/command.c index 7dde20f9a..7a9a074f7 100644 --- a/imap/command.c +++ b/imap/command.c @@ -451,8 +451,14 @@ static void cmd_handle_fatal (IMAP_DATA* idata) idata->state = IMAP_DISCONNECTED; } - if (idata->state < IMAP_SELECTED) - imap_close_connection (idata); + imap_close_connection (idata); + if (!idata->recovering) + { + idata->recovering = 1; + if (imap_conn_find (&idata->conn->account, 0)) + mutt_clear_error (); + idata->recovering = 0; + } } /* cmd_handle_untagged: fallback parser for otherwise unhandled messages. */ diff --git a/imap/imap_private.h b/imap/imap_private.h index 79f75e2ee..9f5d6d50e 100644 --- a/imap/imap_private.h +++ b/imap/imap_private.h @@ -170,6 +170,7 @@ typedef struct { /* This data is specific to a CONNECTION to an IMAP server */ CONNECTION *conn; + unsigned char recovering; unsigned char state; unsigned char status; /* let me explain capstr: SASL needs the capability string (not bits). -- 2.40.0