From ddb6ad5e4757c872d8153072fed52de54561c6a6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 8 Nov 1996 22:11:54 +0000 Subject: We no longer attempt delivery to multidrop mailboxes in the presence of DNS errors. svn path=/trunk/; revision=519 --- driver.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'driver.c') diff --git a/driver.c b/driver.c index 325383ce..11cde20a 100644 --- a/driver.c +++ b/driver.c @@ -120,12 +120,16 @@ static int is_host_alias(const char *name, struct query *ctl) return(TRUE); /* - * We treat DNS lookup failure as a negative on the theory that - * the mailserver's DNS server is `nearby' and should be able - * to respond quickly and reliably. Ergo if we get failure, - * the name isn't a mailserver alias. + * We know DNS service was up at the beginning of this poll cycle. + * If it's down, our nameserver has crashed. We don't want to try + * delivering the current message or anything else from this + * mailbox until it's back up. */ - else if ((he = gethostbyname(name)) && strcmp(ctl->canonical_name, he->h_name) == 0) + else if ((he = gethostbyname(name)) == (struct hostent *)NULL) + longjmp(restart, 2); + + /* DNS response is OK */ + else if (strcmp(ctl->canonical_name, he->h_name) == 0) return(TRUE); /* @@ -138,12 +142,15 @@ static int is_host_alias(const char *name, struct query *ctl) mxrecords = getmxrecords(name); + h_errno = 0; if (mxrecords == (struct mxentry *)NULL) if (h_errno == TRY_AGAIN) { sleep(1); continue; } + else if (h_errno) /* fatal error */ + longjmp(restart, 2); else break; @@ -628,7 +635,7 @@ int do_protocol(ctl, proto) struct query *ctl; /* parsed options with merged-in defaults */ const struct method *proto; /* protocol method table */ { - int ok; + int ok, js; void (*sigsave)(); #ifndef KERBEROS_V4 @@ -673,13 +680,20 @@ const struct method *proto; /* protocol method table */ sigsave = signal(SIGVTALRM, vtalarm_handler); vtalarm(mytimeout = ctl->timeout); - if (setjmp(restart) == 1) + if ((js = setjmp(restart)) == 1) { fprintf(stderr, "fetchmail: timeout after %d seconds waiting for %s.\n", ctl->timeout, ctl->servername); ok = PS_ERROR; } + else if (js == 2) + { + fprintf(stderr, + "fetchmail: nameserver evaporated during poll of %s.\n", + ctl->servername); + ok = PS_ERROR; + } else { char buf [POPBUFSIZE+1]; -- cgit v1.2.3