mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
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:
parent
aeb8d345b4
commit
45eba6ffd5
17
evdns.c
17
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
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user