X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=driver.c;h=c2917268cedfce70fa9d70f085bad27b7f4f201b;hb=b3e0cd2d558b5ccf06c816eed38c883d7462d3d4;hp=5c073d65a4a0183dec222cd63f3d3a5abbba8be3;hpb=48b4421173725c8d2eb9c36342a1a70937c16de0;p=~andy%2Ffetchmail diff --git a/driver.c b/driver.c index 5c073d65..c2917268 100644 --- a/driver.c +++ b/driver.c @@ -438,7 +438,8 @@ static int eat_trailer(int sock, struct query *ctl) static int fetch_messages(int mailserver_socket, struct query *ctl, int count, int **msgsizes, int maxfetch, - int *fetches, int *dispatches, int *deletions) + int *fetches, int *dispatches, int *deletions, + int *transient_errors) /* fetch messages in lockstep mode */ { flag force_retrieval; @@ -511,14 +512,11 @@ static int fetch_messages(int mailserver_socket, struct query *ctl, } if (msgcode == MSGLEN_OLD) { - /* To avoid flooding the syslog when using --keep, - * report "Skipped message" only when: - * 1) --verbose is on, or - * 2) fetchmail does not use syslog - */ - if ( (outlevel >= O_VERBOSE) || - (outlevel > O_SILENT && !run.use_syslog) - ) + /* + * To avoid flooding the logs when using --keep, report + * skipping for old messages only when --flush is on. + */ + if (outlevel > O_SILENT && ctl->flush) { report_build(stdout, GT_("skipping message %s@%s:%d"), @@ -615,6 +613,7 @@ static int fetch_messages(int mailserver_socket, struct query *ctl, GT_("couldn't fetch headers, message %s@%s:%d (%d octets)\n"), ctl->remotename, ctl->server.truename, num, msgsize); + (*transient_errors)++; continue; } else if (err != 0) @@ -656,7 +655,10 @@ static int fetch_messages(int mailserver_socket, struct query *ctl, if (err == PS_RETAINED) suppress_forward = suppress_delete = retained = TRUE; else if (err == PS_TRANSIENT) + { suppress_delete = suppress_forward = TRUE; + (*transient_errors)++; + } else if (err == PS_REFUSED) suppress_forward = TRUE; else if (err) @@ -717,7 +719,10 @@ static int fetch_messages(int mailserver_socket, struct query *ctl, len); if (err == PS_TRANSIENT) + { suppress_delete = suppress_forward = TRUE; + (*transient_errors)++; + } else if (err) return(err); @@ -810,16 +815,11 @@ flagthemail: } else { - if ( (outlevel >= O_VERBOSE) || - /* To avoid flooding the syslog when using --keep, - * report "Skipped message" only when: - * 1) --verbose is on, or - * 2) fetchmail does not use syslog, or - * 3) the message was skipped for some other - * reason than just being old. - */ - (outlevel > O_SILENT && (!run.use_syslog || msgcode != MSGLEN_OLD)) - ) + /* + * To avoid flooding the logs when using --keep, report + * skipping of new messages only. + */ + if (outlevel > O_SILENT && msgcode != MSGLEN_OLD) report_complete(stdout, GT_(" not flushed\n")); /* maybe we mark this message as seen now? */ @@ -948,7 +948,7 @@ static int do_session( /* sigsetjmp returned zero -> normal operation */ char buf[MSGBUFSIZE+1], *realhost; int count, newm, bytes; - int fetches, dispatches, oldphase; + int fetches, dispatches, transient_errors, oldphase; struct idlist *idp; /* execute pre-initialization command, if any */ @@ -1106,6 +1106,7 @@ static int do_session( ctl->sslcommonname : realhost, ctl->server.pollname, &ctl->remotename) == -1) { + set_timeout(0); report(stderr, GT_("SSL connection failed.\n")); err = PS_SOCKET; goto cleanUp; @@ -1304,6 +1305,7 @@ is restored.")); pass = 0; do { dispatches = 0; + transient_errors = 0; ++pass; /* reset timeout, in case we did an IDLE */ @@ -1433,10 +1435,20 @@ is restored.")); err = fetch_messages(mailserver_socket, ctl, count, &msgsizes, maxfetch, - &fetches, &dispatches, &deletions); + &fetches, &dispatches, &deletions, + &transient_errors); if (err != PS_SUCCESS && err != PS_MAXFETCH) goto cleanUp; + if (transient_errors > MAX_TRANSIENT_ERRORS) + { + if (outlevel > O_SILENT) + { + report(stderr, GT_("Too many mails skipped (%d > %d) due to transient errors for %s\n"), + transient_errors, MAX_TRANSIENT_ERRORS, buf); + } + } + if (!check_only && ctl->skipped && run.poll_interval > 0 && !nodetach) {