From bc0ba46bc4b30dff8459ab55b2c107838558476f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 24 Dec 1996 20:00:28 +0000 Subject: George Sipe's patch. svn path=/trunk/; revision=684 --- fetchmail.c | 102 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 53 insertions(+), 49 deletions(-) (limited to 'fetchmail.c') diff --git a/fetchmail.c b/fetchmail.c index 722ddcf7..bea98e7e 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -167,14 +167,16 @@ int main (int argc, char **argv) printf("SMTP message batch limit is %d.\n", batchlimit); else if (outlevel == O_VERBOSE) printf("No SMTP message batch limit.\n"); +#ifdef linux if (interface) - printf("TCP/IP interface is %s.\n", interface); + printf("TCP/IP interface requirements for %s.\n", interface); else if (outlevel == O_VERBOSE) - printf("No TCP/IP interface specified\n"); + printf("No TCP/IP interface requirements specified\n"); if (monitor) printf("Polling loop will monitor %s.\n", monitor); else if (outlevel == O_VERBOSE) - printf("No monitor address specified\n"); + printf("No monitor interface specified\n"); +#endif for (ctl = querylist; ctl; ctl = ctl->next) { if (ctl->active && !(implicitmode && ctl->skip)) dump_params(ctl); @@ -334,6 +336,54 @@ int main (int argc, char **argv) * reflect the status of that transaction. */ do { + if (poll_interval) + { + if (outlevel == O_VERBOSE) + { + time_t now; + + time(&now); + fprintf(stderr, "fetchmail: sleeping at %s", ctime(&now)); + } + + /* + * We can't use sleep(3) here because we need an alarm(3) + * equivalent in order to implement server nonresponse timeout. + * We'll just assume setitimer(2) is available since fetchmail + * has to have a BSDoid socket layer to work at all. + */ +#ifdef linux + do { + interface_note_activity(); +#endif + { + struct itimerval ntimeout; + + ntimeout.it_interval.tv_sec = ntimeout.it_interval.tv_usec = 0; + ntimeout.it_value.tv_sec = poll_interval; + ntimeout.it_value.tv_usec = 0; + + setitimer(ITIMER_REAL,&ntimeout,NULL); + signal(SIGALRM, donothing); + pause(); + if (lastsig == SIGUSR1) { + signal(SIGALRM, SIG_IGN); + (void) error(0, 0, "awakened by SIGUSR1"); + } + } +#ifdef linux + } while (!interface_approve()); +#endif + + if (outlevel == O_VERBOSE) + { + time_t now; + + time(&now); + fprintf(stderr, "fetchmail: awakened at %s", ctime(&now)); + } + } + #ifdef HAVE_RES_SEARCH sethostent(TRUE); /* use TCP/IP for mailserver queries */ #endif /* HAVE_RES_SEARCH */ @@ -405,52 +455,6 @@ int main (int argc, char **argv) fclose(ctl->smtp_sockfp); ctl->smtp_sockfp = (FILE *)NULL; } - - if (poll_interval) - { - if (outlevel == O_VERBOSE) - { - time_t now; - - time(&now); - fprintf(stderr, "fetchmail: sleeping at %s", ctime(&now)); - } - - /* - * We can't use sleep(3) here because we need an alarm(3) - * equivalent in order to implement server nonresponse timeout. - * We'll just assume setitimer(2) is available since fetchmail - * has to have a BSDoid socket layer to work at all. - */ -#ifdef linux - do { - interface_note_activity(); -#endif - { - struct itimerval ntimeout; - - ntimeout.it_interval.tv_sec = ntimeout.it_interval.tv_usec = 0; - ntimeout.it_value.tv_sec = poll_interval; - ntimeout.it_value.tv_usec = 0; - - setitimer(ITIMER_REAL,&ntimeout,NULL); - signal(SIGALRM, donothing); - pause(); - if (lastsig == SIGUSR1) - (void) error(0, 0, "awakened by SIGUSR1"); - } -#ifdef linux - } while (!interface_approve()); -#endif - - if (outlevel == O_VERBOSE) - { - time_t now; - - time(&now); - fprintf(stderr, "fetchmail: awakened at %s", ctime(&now)); - } - } } while (poll_interval); -- cgit v1.2.3