Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try (once) to reconnect after an IMAP failure #366

Merged
merged 2 commits into from Feb 6, 2017
Merged

Conversation

gahr
Copy link
Member

@gahr gahr commented Feb 5, 2017

Closes #346

@gahr
Copy link
Member Author

gahr commented Feb 5, 2017

@neomutt/reviewers Please review

Copy link
Member

@flatcap flatcap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... the code seems too simple to be that useful.

Killing the connection with tcpkill causes it to reconnect (once).
Kill it again and the mailbox is left closed.

Nice.

imap/command.c Outdated
@@ -440,6 +440,7 @@ static int cmd_status (const char *s)
/* cmd_handle_fatal: when IMAP_DATA is in fatal state, do what we can */
static void cmd_handle_fatal (IMAP_DATA* idata)
{
static int try_reconnect = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we keep the function reentrant by moving this to IMAP_DATA? Otherwise 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is reentrant, just it doesn't behave the same once reentred ;) I don't see a benefit to moving this local piece of data to IMAP_DATA. What am I missing?

@gahr
Copy link
Member Author

gahr commented Feb 6, 2017

Kill it again and the mailbox is left closed.

@flatcap that is surprising... the "once" in the comment was meant to be "once per failure", that is, if mutt can't re-establish a connection on failure, it doesn't try again. That's the reason for the try_connect static var.

If it doesn't reconnect upon a second (unrelated, long after reconnection) failure, then there's still something I have to look at.

Copy link
Contributor

@d-k-c d-k-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Note for other readers: IMAP_DATA is allocated with safe_calloc, so this new member will be correctly initialized.

@gahr gahr merged commit d89559a into neomutt Feb 6, 2017
@gahr gahr removed the status:ready label Feb 6, 2017
@flatcap flatcap deleted the devel/issue-346 branch February 6, 2017 22:54
@flatcap flatcap added this to the next-release milestone Feb 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement Feature Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants