aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--imap.c19
2 files changed, 18 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index d902dad8..c03432b0 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,9 @@
* Added Andrey Lelikov's recupe for Hotmail and Lycos Webmail.
* Switched to automake. (Matthias Andree)
* Build fixes for HESIOD and resolv.h trouble on FreeBSD. (Matthias Andree)
+* Fabrice Bellet's fix for Red Hat bug #113492, fetchmail hangs in IMAP
+ mode after EXPUNGE when the server (Dovecot 0.99.10) doesn't update
+ RECENT and EXISTS counts. (Matthias Andree)
fetchmail-6.2.5 (Wed Oct 15 18:39:22 EDT 2003), 23079 lines:
diff --git a/imap.c b/imap.c
index af930b48..ff727e7e 100644
--- a/imap.c
+++ b/imap.c
@@ -32,6 +32,7 @@ extern char *strstr(const char *, const char *); /* needed on sysV68 R3V7.1. */
#define IMAP4rev1 1 /* IMAP4 rev 1, RFC2060 */
static int count = 0, recentcount = 0, unseen = 0, deletions = 0;
+static int recentcount_ok = 0;
static unsigned int startcount = 1;
static int expunged, expunge_period, saved_timeout = 0;
static int imap_version, preauth;
@@ -103,8 +104,15 @@ static int imap_ok(int sock, char *argbuf)
/* a space is required to avoid confusion with the \Recent flag */
else if (strstr(buf, " RECENT"))
{
+ recentcount_ok = 1;
recentcount = atoi(buf+2);
}
+ else if (strstr(buf, "EXPUNGE") && !strstr(buf, "OK"))
+ {
+ count -= atoi(buf+2);
+ if (count < 0)
+ count = 0;
+ }
else if (strstr(buf, "PREAUTH"))
preauth = TRUE;
/*
@@ -547,9 +555,16 @@ static int internal_expunge(int sock)
{
int ok;
+ recentcount_ok = 0;
+
if ((ok = gen_transact(sock, "EXPUNGE")))
return(ok);
+ /* some servers do not report RECENT after an EXPUNGE. in this case,
+ * the previous value of recentcount is just ignored. */
+ if (!recentcount_ok)
+ recentcount = 0;
+
expunged += deletions;
deletions = 0;
@@ -650,10 +665,6 @@ static int imap_getrange(int sock,
* for new mail.
*/
- /* some servers do not report RECENT after an EXPUNGE. this check
- * forces an incorrect recentcount to be ignored. */
- if (recentcount > count)
- recentcount = 0;
/* this is a while loop because imap_idle() might return on other
* mailbox changes also */
while (recentcount == 0 && do_idle) {