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) ...@@ -1562,6 +1562,11 @@ imap_readline (f_imap_t f_imap)
1562 if (status != 0) 1562 if (status != 0)
1563 return status; 1563 return status;
1564 1564
1565 /* The server went away: It maybe a timeout and some imap server
1566 does not send the BYE. Consider like an error. */
1567 if (n == 0)
1568 return EIO;
1569
1565 total += n; 1570 total += n;
1566 f_imap->offset += n; 1571 f_imap->offset += n;
1567 f_imap->nl = memchr (f_imap->buffer, '\n', total); 1572 f_imap->nl = memchr (f_imap->buffer, '\n', total);
......
...@@ -538,7 +538,12 @@ pop_open (mailbox_t mbox, int flags) ...@@ -538,7 +538,12 @@ pop_open (mailbox_t mbox, int flags)
538 url_get_auth (mbox->url, auth, sizeof (auth), &n); 538 url_get_auth (mbox->url, auth, sizeof (auth), &n);
539 if (n == 0 || strcasecmp (auth, "*") == 0) 539 if (n == 0 || strcasecmp (auth, "*") == 0)
540 { 540 {
541 authority_create (&(mbox->authority), mbox->ticket, mbox); 541 ticket_t ticket = NULL;
542 if (mbox->folder)
543 folder_get_ticket (mbox->folder, &ticket);
544 if (ticket == NULL)
545 ticket = mbox->ticket;
546 authority_create (&(mbox->authority), ticket, mbox);
542 authority_set_authenticate (mbox->authority, pop_user, mbox); 547 authority_set_authenticate (mbox->authority, pop_user, mbox);
543 } 548 }
544 else if (strcasecmp (auth, "+apop") == 0) 549 else if (strcasecmp (auth, "+apop") == 0)
...@@ -1815,6 +1820,11 @@ pop_readline (pop_data_t mpd) ...@@ -1815,6 +1820,11 @@ pop_readline (pop_data_t mpd)
1815 if (status != 0) 1820 if (status != 0)
1816 return status; 1821 return status;
1817 1822
1823 /* The server went away: It maybe a timeout and some pop server
1824 does not send the -ERR. Consider this like an error. */
1825 if (n == 0)
1826 return EIO;
1827
1818 total += n; 1828 total += n;
1819 mpd->offset += n; 1829 mpd->offset += n;
1820 mpd->nl = memchr (mpd->buffer, '\n', total); 1830 mpd->nl = memchr (mpd->buffer, '\n', total);
......
...@@ -822,6 +822,10 @@ smtp_readline (smtp_t smtp) ...@@ -822,6 +822,10 @@ smtp_readline (smtp_t smtp)
822 if (status != 0) 822 if (status != 0)
823 return status; 823 return status;
824 824
825 /* Server went away, consider this like an error. */
826 if (n == 0)
827 return EIO;
828
825 total += n; 829 total += n;
826 smtp->nl = memchr (smtp->buffer, '\n', total); 830 smtp->nl = memchr (smtp->buffer, '\n', total);
827 if (smtp->nl == NULL) /* Do we have a full line. */ 831 if (smtp->nl == NULL) /* Do we have a full line. */
......