From 3b1e076e2d58a753bf088a7bcdf442d1a387c0d0 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 20 Nov 1996 03:08:40 +0000 Subject: Caching via aka list. svn path=/trunk/; revision=563 --- driver.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'driver.c') diff --git a/driver.c b/driver.c index bdf033f0..af14372e 100644 --- a/driver.c +++ b/driver.c @@ -119,6 +119,13 @@ static int is_host_alias(const char *name, struct query *ctl) else if (strcmp(name, ctl->canonical_name) == 0) return(TRUE); + /* + * Is it in the `also known as' cache accumulated by previous DNS checks? + * This cache may someday be primed by an aka option. + */ + else if (uid_in_list(&ctl->lead_server->aka, name)) + return(TRUE); + /* * 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 @@ -126,7 +133,12 @@ static int is_host_alias(const char *name, struct query *ctl) * mailbox until it's back up. */ else if ((he = gethostbyname(name)) != (struct hostent *)NULL) - return(strcmp(ctl->canonical_name, he->h_name) == 0); + { + if (strcmp(ctl->canonical_name, he->h_name) == 0) + goto match; + else + return(FALSE); + } else switch (h_errno) { @@ -162,7 +174,7 @@ static int is_host_alias(const char *name, struct query *ctl) case NO_ADDRESS: /* valid, but does not have an IP address */ for (mxp = mxrecords; mxp->name; mxp++) if (strcmp(name, mxp->name) == 0) - return(TRUE); + goto match; break; case NO_RECOVERY: /* non-recoverable name server error */ @@ -177,6 +189,11 @@ static int is_host_alias(const char *name, struct query *ctl) } return(FALSE); + +match: + /* add this name to relevant server's `also known as' list */ + save_uid(&ctl->lead_server->aka, -1, name); + return(TRUE); } void find_server_names(hdr, ctl, xmit_names) @@ -226,7 +243,7 @@ struct idlist **xmit_names; /* list of recipient names parsed out */ static FILE *smtp_open(struct query *ctl) /* try to open a socket to the appropriate SMTP server for this query */ { - ctl = ctl->leader; /* go to the SMTP leader for this query */ + ctl = ctl->lead_smtp; /* go to the SMTP leader for this query */ /* maybe it's time to close the socket in order to force delivery */ if (batchlimit && ctl->smtp_sockfp && batchcount++ == batchlimit) -- cgit v1.2.3