]> Pileus Git - ~andy/fetchmail/blobdiff - driver.c
Cosmetic cleanup.
[~andy/fetchmail] / driver.c
index 9c8c61597ca167345394ae5ed644cdfb8f78be0b..26ff2879f0edd277545dd391ba3c3913a6fc5a6c 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -82,6 +82,7 @@ flag peek_capable;    /* can we peek for better error recovery? */
 int pass;              /* how many times have we re-polled? */
 int stage;             /* where are we? */
 int phase;             /* where are we, for error-logging purposes? */
+int mytimeout;         /* value of nonreponse timeout */
 
 static const struct method *protocol;
 static jmp_buf restart;
@@ -91,7 +92,6 @@ static int tagnum;
 #define GENSYM (sprintf(tag, "A%04d", ++tagnum % TAGMOD), tag)
 
 static char shroud[PASSWORDLEN];       /* string to shroud in debug output */
-static int mytimeout;                  /* value of nonreponse timeout */
 static int timeoutcount;               /* count consecutive timeouts */
 static int msglen;                     /* actual message length */
 
@@ -726,14 +726,14 @@ static int readheaders(int sock,
            resent_sender_offs = (line - msgblk.headers);
 
 #ifdef __UNUSED__
-       else if (!strncasecmp("Message-Id:", buf, 11))
+       else if (!strncasecmp("Message-Id:", line, 11))
        {
            if (ctl->server.uidl)
            {
                char id[IDLEN+1];
 
-               buf[IDLEN+12] = 0;              /* prevent stack overflow */
-               sscanf(buf+12, "%s", id);
+               line[IDLEN+12] = 0;             /* prevent stack overflow */
+               sscanf(line+12, "%s", id);
                if (!str_find( &ctl->newsaved, num))
                {
                    struct idlist *new = save_str(&ctl->newsaved,id,UID_SEEN);
@@ -1513,6 +1513,8 @@ const int maxfetch;               /* maximum number of messages to fetch */
            /*
             * If we've exceeded our threshold for consecutive timeouts, 
             * try to notify the user, then mark the connection wedged.
+            * Don't do this if the connection can idle, though; idle
+            * timeouts just mean the frequency of mail is low.
             */
            if (timeoutcount > MAX_TIMEOUTS 
                && !open_warning_by_mail(ctl, (struct msgblk *)NULL))
@@ -1755,6 +1757,9 @@ const int maxfetch;               /* maximum number of messages to fetch */
                dispatches = 0;
                ++pass;
 
+               /* reset timeout, in case we did an IDLE */
+               mytimeout = ctl->server.timeout;
+
                if (outlevel >= O_DEBUG)
                {
                    if (idp->id)
@@ -1813,7 +1818,12 @@ const int maxfetch;              /* maximum number of messages to fetch */
                    if (new == -1 || ctl->fetchall)
                        new = count;
                    fetches = new;      /* set error status ccorrectly */
-                   goto no_error;
+                   /*
+                    * There used to be a `got noerror' here, but this
+                    * prevneted checking of multiple folders.  This
+                    * comment is a reminder in case I introduced some
+                    * subtle bug by removing it...
+                    */
                }
                else if (count > 0)
                {    
@@ -2196,8 +2206,8 @@ const int maxfetch;               /* maximum number of messages to fetch */
                }
            } while
                  /*
-                  * Only re-poll if we had some actual forwards, allowed
-                  * deletions and had no errors.
+                  * Only re-poll if we either had some actual forwards and 
+                  * either allowed deletions and had no errors.
                   * Otherwise it is far too easy to get into infinite loops.
                   */
                  (dispatches && protocol->retry && !ctl->keep && !ctl->errcount);