diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2004-09-10 12:06:52 +0000 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2004-09-10 12:06:52 +0000 |
commit | 05719c0970f03711c66c013ba53f54b097882e15 (patch) | |
tree | cb57211a79ecdf0ccd2036fbe1c3c0b1d85df3d4 /imap.c | |
parent | abaaa2765eeae975484da526384b0f34570c52e2 (diff) | |
download | fetchmail-05719c0970f03711c66c013ba53f54b097882e15.tar.gz fetchmail-05719c0970f03711c66c013ba53f54b097882e15.tar.bz2 fetchmail-05719c0970f03711c66c013ba53f54b097882e15.zip |
Merge Fabrice Bellet's patch to fix recentcount/count after IMAP
EXPUNGE, to fix a hang after EXPUNGE for servers that don't update the
number of RECENT and EXISTS messages such as Dovecot 0.99.10.
Fixes Red Hat bug #113492.
Credits:
Fabrice Bellet (patch)
Timo Sirainen (patch assistance)
Alexandre Oliva (bug report)
References:
http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=113492
http://bugzilla.redhat.com/bugzilla/attachment.cgi?id=100788&action=view
http://lists.ccil.org/pipermail/fetchmail-friends/2004-June/008840.html
svn path=/trunk/; revision=3938
Diffstat (limited to 'imap.c')
-rw-r--r-- | imap.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -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) { |