]> Pileus Git - ~andy/fetchmail/commitdiff
Make IMAP4 IDLE work on servers that do not update RECENT counts. Reported by Lars...
authorMatthias Andree <matthias.andree@gmx.de>
Mon, 15 May 2006 16:11:06 +0000 (16:11 -0000)
committerMatthias Andree <matthias.andree@gmx.de>
Mon, 15 May 2006 16:11:06 +0000 (16:11 -0000)
svn path=/branches/BRANCH_6-3/; revision=4842

NEWS
imap.c

diff --git a/NEWS b/NEWS
index 65ecf1d31187df0f7cf7cbbda9dc8c79e43681a6..a5c07bb9a3aa34478bd1a3ac86d8056b7915e9c1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,8 @@ fetchmail 6.3.5 (not yet released):
 * Provide INET6 to KAME/getnameinfo.c (only useful on IPv6-enabled systems that
   lack getnameinfo, and there only visible in some Received: headers).
   Found by Dan Fandrich.
+* Make IMAP4 IDLE work on servers that do not update RECENT counts.
+  Reported by Lars Tewes.
 
 # CHANGES:
 * Rename all fetchmail-internal lock_* functions to fm_lock_*. Obsoletes
diff --git a/imap.c b/imap.c
index 93b9729aa6513620ff124470ab43a5b1b017feb0..b7db68ff1b12cb2b9597d29f23e207d1f95caef4 100644 (file)
--- a/imap.c
+++ b/imap.c
@@ -679,7 +679,7 @@ static int imap_getrange(int sock,
                         int *countp, int *newp, int *bytes)
 /* get range of messages to be fetched */
 {
-    int ok;
+    int ok, oldcount;
     char buf[MSGBUFSIZE+1], *cp;
 
     /* find out how many messages are waiting */
@@ -696,7 +696,9 @@ static int imap_getrange(int sock,
         *
         * this is a while loop because imap_idle() might return on other
         * mailbox changes also */
-       while (recentcount == 0 && do_idle) {
+       oldcount = count;
+       while (count <= oldcount && recentcount == 0 && do_idle) {
+           oldcount = count;
            smtp_close(ctl, 1);
            ok = imap_idle(sock);
            if (ok)
@@ -706,7 +708,7 @@ static int imap_getrange(int sock,
            }
        }
        /* if recentcount is 0, return no mail */
-       if (recentcount == 0)
+       if (recentcount == 0 && count <= oldcount)
                count = 0;
        if (outlevel >= O_DEBUG)
            report(stdout, ngettext("%d message waiting after re-poll\n",