From 07e6eecdb2df0b4130201c4252770724f74c642c Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 2 Feb 2007 18:58:04 +0000 Subject: [PATCH] r12122@Kushana: nickm | 2007-02-02 10:41:39 -0500 Fail when we are unable to parse the nameserver configuration. svn:r9475 --- ChangeLog | 1 + src/or/config.c | 6 ++++-- src/or/dns.c | 11 ++++++----- src/or/or.h | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 743a2c00c5..ee9e3828e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -63,6 +63,7 @@ Changes in version 0.1.2.7-alpha - 2007-??-?? - Handle TTL values correctly on reverse DNS lookups. - Stop using the reserved ac_cv namespace in our configure script. - Call stat() slightly less often; use fstat() when possible. + - Treat failure to parse resolv.conf as an error. o Major features: - Weight directory requests by advertised bandwidth. Now we can diff --git a/src/or/config.c b/src/or/config.c index d332c60fbc..7d7e788f0a 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -990,11 +990,13 @@ options_act(or_options_t *old_options) inform_testing_reachability(); } cpuworkers_rotate(); - dns_reset(); + if (dns_reset()) + return -1; } #ifdef USE_EVENTDNS else { - dns_reset(); + if (dns_reset()) + return -1; } #endif } diff --git a/src/or/dns.c b/src/or/dns.c index c86bd9c571..b7f27c64bb 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -222,8 +222,9 @@ dns_init(void) return 0; } -/** Called when DNS-related options change (or may have changed) */ -void +/** Called when DNS-related options change (or may have changed). Returns -1 + * on failure, 0 on success. */ +int dns_reset(void) { #ifdef USE_EVENTDNS @@ -236,8 +237,7 @@ dns_reset(void) resolv_conf_mtime = 0; } else { if (configure_nameservers(0) < 0) - /* XXXX012 */ - return; + return -1; } #else dnsworkers_rotate(); @@ -322,7 +322,8 @@ dns_free_all(void) SMARTLIST_FOREACH(cached_resolve_pqueue, cached_resolve_t *, res, { /* XXXX012 The hash lookups here could be quite slow; remove them - * once we're happy. */ + * once we're happy. (Leave them in for at least 0.1.2.7-alpha, so they + * get some testing.) -NM */ if (res->state == CACHE_STATE_DONE) { cached_resolve_t *found = HT_FIND(cache_map, &cache_root, res); tor_assert(!found || found != res); diff --git a/src/or/or.h b/src/or/or.h index 83607af3ee..303f3d2e04 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2415,7 +2415,7 @@ uint32_t dns_clip_ttl(uint32_t ttl); int connection_dns_finished_flushing(connection_t *conn); int connection_dns_reached_eof(connection_t *conn); int connection_dns_process_inbuf(connection_t *conn); -void dns_reset(void); +int dns_reset(void); void connection_dns_remove(edge_connection_t *conn); void assert_connection_edge_not_dns_pending(edge_connection_t *conn); void assert_all_pending_dns_resolves_ok(void);