diff --git a/evdns.c b/evdns.c index 04362a32..28ea0f6c 100644 --- a/evdns.c +++ b/evdns.c @@ -4045,16 +4045,15 @@ evdns_base_free(struct evdns_base *base, int fail_requests) } void -evdns_base_flush_outdated_host_addresses(struct evdns_base *base) +evdns_base_clear_host_addresses(struct evdns_base *base) { - EVDNS_LOCK(base); - struct hosts_entry *victim; - while ((victim = TAILQ_FIRST(&base->hostsdb))) { - TAILQ_REMOVE(&base->hostsdb, victim, next); - mm_free(victim); - } - EVDNS_UNLOCK(base); - EVTHREAD_FREE_LOCK(base->lock, EVTHREAD_LOCKTYPE_RECURSIVE); + EVDNS_LOCK(base); + struct hosts_entry *victim; + while ((victim = TAILQ_FIRST(&base->hostsdb))) { + TAILQ_REMOVE(&base->hostsdb, victim, next); + mm_free(victim); + } + EVDNS_UNLOCK(base); } void diff --git a/include/event2/dns.h b/include/event2/dns.h index b7ca0937..fd4dec68 100644 --- a/include/event2/dns.h +++ b/include/event2/dns.h @@ -237,11 +237,13 @@ struct evdns_base * evdns_base_new(struct event_base *event_base, int initialize */ void evdns_base_free(struct evdns_base *base, int fail_requests); -/** - All previous outdated host addresses will be removed or flushed from the event base. - @param evdns_base the evdns base to flush outdated host addresses -*/ -void evdns_base_flush_outdated_host_addresses(struct evdns_base *base); +/** + Remove all hosts entries that have been loaded into the event_base via + evdns_base_load_hosts or via event_base_resolv_conf_parse. + + @param evdns_base the evdns base to remove outdated host addresses from + */ +void evdns_base_clear_host_addresses(struct evdns_base *base); /** Convert a DNS error code to a string. @@ -449,6 +451,9 @@ int evdns_base_resolv_conf_parse(struct evdns_base *base, int flags, const char Note that only evdns_getaddrinfo uses the /etc/hosts entries. + This function does not replace previously loaded hosts entries; to do that, + call evdns_base_clear_host_addresses first. + Return 0 on success, negative on failure. */ int evdns_base_load_hosts(struct evdns_base *base, const char *hosts_fname);