Rename flush_outdated_host_addresses to clear_host_addresses

"flush" can imply writing something out to a file or connection before
clearing it; "clear" always means "remove".  It's also potentially
misleading to say "outdated" here, since the function removes _all_
addresses regardless, not just certain outdated ones.

Also, don't free the lock in this function.  Also reindent the function.
This commit is contained in:
Nick Mathewson 2013-12-06 10:50:17 -05:00
parent aeb8d345b4
commit 45eba6ffd5
2 changed files with 18 additions and 14 deletions

View File

@ -4045,7 +4045,7 @@ evdns_base_free(struct evdns_base *base, int fail_requests)
} }
void void
evdns_base_flush_outdated_host_addresses(struct evdns_base *base) evdns_base_clear_host_addresses(struct evdns_base *base)
{ {
EVDNS_LOCK(base); EVDNS_LOCK(base);
struct hosts_entry *victim; struct hosts_entry *victim;
@ -4054,7 +4054,6 @@ evdns_base_flush_outdated_host_addresses(struct evdns_base *base)
mm_free(victim); mm_free(victim);
} }
EVDNS_UNLOCK(base); EVDNS_UNLOCK(base);
EVTHREAD_FREE_LOCK(base->lock, EVTHREAD_LOCKTYPE_RECURSIVE);
} }
void void

View File

@ -238,10 +238,12 @@ struct evdns_base * evdns_base_new(struct event_base *event_base, int initialize
void evdns_base_free(struct evdns_base *base, int fail_requests); 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. Remove all hosts entries that have been loaded into the event_base via
@param evdns_base the evdns base to flush outdated host addresses evdns_base_load_hosts or via event_base_resolv_conf_parse.
*/
void evdns_base_flush_outdated_host_addresses(struct evdns_base *base); @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. 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. 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. Return 0 on success, negative on failure.
*/ */
int evdns_base_load_hosts(struct evdns_base *base, const char *hosts_fname); int evdns_base_load_hosts(struct evdns_base *base, const char *hosts_fname);