Commit 408d5f84 408d5f84a35acbfb7efc7cde25bb48a6eee7f91b by Alain Magloire

return an erro if the servers goes away suddenly.

1 parent 0ef1f36c
......@@ -1562,6 +1562,11 @@ imap_readline (f_imap_t f_imap)
if (status != 0)
return status;
/* The server went away: It maybe a timeout and some imap server
does not send the BYE. Consider like an error. */
if (n == 0)
return EIO;
total += n;
f_imap->offset += n;
f_imap->nl = memchr (f_imap->buffer, '\n', total);
......
......@@ -538,7 +538,12 @@ pop_open (mailbox_t mbox, int flags)
url_get_auth (mbox->url, auth, sizeof (auth), &n);
if (n == 0 || strcasecmp (auth, "*") == 0)
{
authority_create (&(mbox->authority), mbox->ticket, mbox);
ticket_t ticket = NULL;
if (mbox->folder)
folder_get_ticket (mbox->folder, &ticket);
if (ticket == NULL)
ticket = mbox->ticket;
authority_create (&(mbox->authority), ticket, mbox);
authority_set_authenticate (mbox->authority, pop_user, mbox);
}
else if (strcasecmp (auth, "+apop") == 0)
......@@ -1815,6 +1820,11 @@ pop_readline (pop_data_t mpd)
if (status != 0)
return status;
/* The server went away: It maybe a timeout and some pop server
does not send the -ERR. Consider this like an error. */
if (n == 0)
return EIO;
total += n;
mpd->offset += n;
mpd->nl = memchr (mpd->buffer, '\n', total);
......
......@@ -822,6 +822,10 @@ smtp_readline (smtp_t smtp)
if (status != 0)
return status;
/* Server went away, consider this like an error. */
if (n == 0)
return EIO;
total += n;
smtp->nl = memchr (smtp->buffer, '\n', total);
if (smtp->nl == NULL) /* Do we have a full line. */
......