]> Pileus Git - ~andy/fetchmail/commitdiff
Arrange for fetchall to be forced on after transient errors abort a
authorEric S. Raymond <esr@thyrsus.com>
Thu, 14 Nov 1996 23:45:06 +0000 (23:45 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 14 Nov 1996 23:45:06 +0000 (23:45 -0000)
poll cycle.

svn path=/trunk/; revision=540

driver.c
fetchmail.h
fetchmail.man
options.c

index 51e0fedc77b667db5011136a79f525d574af9a64..fde38a464c8089e98e847b86e2ac6b9ee6a5f519 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -141,8 +141,9 @@ static int is_host_alias(const char *name, struct query *ctl)
            if (outlevel != O_SILENT)
                putchar('\n');  /* terminate the progress message */
            fprintf(stderr,
-               "fetchmail: nameserver evaporated while looking for `%s' during poll of %s.\n",
+               "fetchmail: nameserver failure while looking for `%s' during poll of %s.\n",
                name, ctl->servername);
+           ctl->errcount++;
            longjmp(restart, 2);        /* try again next poll cycle */
            break;
        }
@@ -168,6 +169,10 @@ static int is_host_alias(const char *name, struct query *ctl)
        case NO_RECOVERY:       /* non-recoverable name server error */
        case TRY_AGAIN:         /* temporary error on authoritative server */
        default:
+           fprintf(stderr,
+               "fetchmail: nameserver failure while looking for `%s' during poll of %s.\n",
+               name, ctl->servername);
+           ctl->errcount++;
            longjmp(restart, 2);        /* try again next poll cycle */
            break;
        }
@@ -778,6 +783,7 @@ const struct method *proto; /* protocol method table */
                return(PS_ERROR);
        }
 
+
        if (check_only)
        {
            if (new == -1 || ctl->fetchall)
@@ -787,12 +793,35 @@ const struct method *proto;       /* protocol method table */
        }
        else if (count > 0)
        {    
+           /*
+            * What forces this code is that in POP3 you can't fetch a
+            * message without having it marked `seen'.
+            *
+            * The result is that if there's any kind of transient error
+            * (DNS lookup failure, or sendmail refusing delivery due to
+            * process-table limits) the message will be marked "seen" on
+            * the server without having been delivered.  This is not a
+            * big problem if fetchmail is running in foreground, because
+            * the user will see a "skipped" message when it next runs and
+            * get clued in.
+            *
+            * But in daemon mode this leads to the message being silently
+            * ignored forever.  This is not acceptable.
+            *
+            * We compensate for this by checking the error count from the 
+            * previous pass and forcing all messages to be considered new
+            * if it's nonzero.
+            */
+           int force_retrieval = (ctl->errcount > 0);
+
+           ctl->errcount = 0;
+
            /* read, forward, and delete messages */
            for (num = 1; num <= count; num++)
            {
-               int     toolarge = msgsizes && msgsizes[num-1]>ctl->limit;
+               int     toolarge = msgsizes && (msgsizes[num-1] > ctl->limit);
                int     fetch_it = ctl->fetchall ||
-                   (!(protocol->is_old && (protocol->is_old)(sockfp,ctl,num)) && !toolarge);
+                   (!toolarge && (force_retrieval || !(protocol->is_old && (protocol->is_old)(sockfp,ctl,num)));
 
                /* we may want to reject this message if it's old */
                if (!fetch_it)
index 93ec9131e42c4a75b401b209e22e76fa47c4f630..b1ebf927f7d7b2dc925e97804949de895ed2c3d3 100644 (file)
@@ -92,6 +92,7 @@ struct query
 
     /* internal use */
     int active;
+    int errcount;              /* count transient errors in last pass */
     struct query *next;                /* next query control block in chain */
     struct query *leader;      /* pointer to this query's SMTP leader */
     FILE *smtp_sockfp;         /* socket descriptor for SMTP connection */
index 054225ef4ed621825a953397ee19d80260c72d76..be3c558c1a5ce0fff399d139dba52d01fbc432ff 100644 (file)
@@ -332,7 +332,9 @@ The
 or --nodetach option suppresses detachment of the daemon process
 from its control terminal.  This is primarily useful for debugging.
 .PP
-Note that running fetchmail in daemon mode forces the --fetchall option on.
+Note that while running in daemon mode, transient errors (such as DNS
+failures or sendmail delivery refusals) effectively force the fetchall
+option on for the duration of the next polling cycle.
 This is a robustness feature.  It means that if a message is fetched
 (and thus marked seen by the mailserver) but not delivered locally
 due to some transient error, it will be re-fetched during the next
index d557fc88864d7cb35c76d66a977c7c76bd50d5e5..4f1cd937a15294d9f3343982d9bb7f7630ac3c49 100644 (file)
--- a/options.c
+++ b/options.c
@@ -130,7 +130,6 @@ struct query *ctl;  /* option record to be initialized */
        case 'd':
        case LA_DAEMON:
            poll_interval = atoi(optarg);
-           ctl->fetchall = TRUE;
            break;
        case 'N':
        case LA_NODETACH: