diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1996-10-29 18:43:02 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1996-10-29 18:43:02 +0000 |
commit | d876ad63e12c57aebc5e6d979db9fe57fe951c8a (patch) | |
tree | 87a3ee87ecfa9dd3063dc1513b321ea88897f7d0 /fetchmail.c | |
parent | 45fa6631f675abd76759238ce665ce960fdcbf5f (diff) | |
download | fetchmail-d876ad63e12c57aebc5e6d979db9fe57fe951c8a.tar.gz fetchmail-d876ad63e12c57aebc5e6d979db9fe57fe951c8a.tar.bz2 fetchmail-d876ad63e12c57aebc5e6d979db9fe57fe951c8a.zip |
Fix the damn single-poll-loop bug.
svn path=/trunk/; revision=420
Diffstat (limited to 'fetchmail.c')
-rw-r--r-- | fetchmail.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/fetchmail.c b/fetchmail.c index 7d9a71ca..c834db6a 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -26,6 +26,7 @@ #include <sys/file.h> #include <sys/wait.h> #include <sys/stat.h> +#include <sys/time.h> #include <fcntl.h> #ifdef HAVE_GETHOSTBYNAME @@ -519,8 +520,27 @@ char **argv; time(&now); fprintf(stderr, "fetchmail: sleeping at %s", ctime(&now)); } - if (sleep(poll_interval)) - (void) fputs("fetchmail: awakened by SIGHUP\n", stderr); + + /* + * We can't use sleep(3) here, the alarm(2) call used to + * implement server nonresponse timeout collides with it. + * We'll just assume setitimer(2) is available since fetchmail + * has to have the socket layer to work at all. + */ + { + struct itimerval ntimeout; + + ntimeout.it_interval.tv_sec = ntimeout.it_interval.tv_sec = 0; + ntimeout.it_value.tv_sec = poll_interval; + ntimeout.it_value.tv_usec = 0; + + if (setitimer(ITIMER_REAL,&ntimeout,(struct itimerval *)NULL)==-1 + && errno == EINTR) + (void) fputs("fetchmail: awakened by SIGHUP\n", stderr); + signal(SIGALRM, donothing); + pause(); + } + if (outlevel == O_VERBOSE) { time_t now; |