diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2011-03-23 20:38:57 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2011-03-23 20:38:57 +0000 |
commit | b47e1d8a7d3952a94f686af0cb82fd6459a1785f (patch) | |
tree | 35a7f0b34e1c7b1ae02d5c5312c421a5b3003fc7 /usr.sbin/smtpd/dns.c | |
parent | ff0815fd7536cde9bc984f06b83fe9c842244d59 (diff) |
Simplify resolver initialization. This is done only once
since resolv.conf reloading is handled automatically by asr.
ok gilles@
Diffstat (limited to 'usr.sbin/smtpd/dns.c')
-rw-r--r-- | usr.sbin/smtpd/dns.c | 49 |
1 files changed, 3 insertions, 46 deletions
diff --git a/usr.sbin/smtpd/dns.c b/usr.sbin/smtpd/dns.c index 9a6358a1a09..36bbf407c5d 100644 --- a/usr.sbin/smtpd/dns.c +++ b/usr.sbin/smtpd/dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dns.c,v 1.30 2011/03/09 00:35:42 todd Exp $ */ +/* $OpenBSD: dns.c,v 1.31 2011/03/23 20:38:56 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -42,8 +42,6 @@ #include "smtpd.h" #include "log.h" -void dns_setup(void); -int dns_resolver_updated(void); struct dnssession *dnssession_init(struct smtpd *, struct dns *); void dnssession_destroy(struct smtpd *, struct dnssession *); void dnssession_mx_insert(struct dnssession *, struct mx *); @@ -105,54 +103,13 @@ dns_query_ptr(struct smtpd *env, struct sockaddr_storage *ss, u_int64_t id) } /* LKA interface */ -int -dns_resolver_updated(void) -{ - struct stat sb; - static time_t mtime = 0; - - /* first run, we need a resolver context */ - if (mtime == 0) - return 1; - - if (stat(_PATH_RESCONF, &sb) < 0) { - log_warnx("dns_resolver_updated: please check %s", - _PATH_RESCONF); - return 0; - } - - /* no change since last time */ - if (mtime == sb.st_mtime) - return 0; - - /* resolv.conf has been updated */ - mtime = sb.st_mtime; - return 1; -} - -void -dns_setup(void) -{ - if (asr) - asr_done(asr); - - asr = asr_resolver(NULL); - if (asr == NULL) - log_warnx("dns_setup: unable to initialize resolver, " - "please check /etc/resolv.conf"); -} - void dns_async(struct smtpd *env, struct imsgev *asker, int type, struct dns *query) { struct dnssession *dnssession; - if (dns_resolver_updated()) - dns_setup(); - - if (asr == NULL) { - log_warnx("dns_async: resolver is disabled, please check %s", - _PATH_RESCONF); + if (asr == NULL && (asr = asr_resolver(NULL)) == NULL) { + log_warnx("dns_async: cannot create resolver"); goto noasr; } |