From 954d2f94c047d2ecfd81e61f402096da9ab61f6e Mon Sep 17 00:00:00 2001 From: Kuldeep Gupta Date: Fri, 6 Dec 2013 16:53:16 +0530 Subject: [PATCH 1/2] bug fix for issues #293 evdns_base_load_hosts doesn't remove outdated adresses As mentioned at https://sourceforge.net/p/levent/bugs/293/ created a small function "evdns_base_flush_outdated_host_addresses" which removes all the previous requests of hosts , if user wants to clean up the list of hosts can call and use this function. Requires function declaration to be added in include/event2/dns.h Adding it in another patch for the same bug. --- evdns.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/evdns.c b/evdns.c index 66a3bff3..04362a32 100644 --- a/evdns.c +++ b/evdns.c @@ -4044,6 +4044,19 @@ evdns_base_free(struct evdns_base *base, int fail_requests) evdns_base_free_and_unlock(base, fail_requests); } +void +evdns_base_flush_outdated_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); +} + void evdns_shutdown(int fail_requests) { From f03d3535afad5b450f141148b0d1534d7c86bfe9 Mon Sep 17 00:00:00 2001 From: Kuldeep Gupta Date: Fri, 6 Dec 2013 17:06:20 +0530 Subject: [PATCH 2/2] bug fix for issues #293 evdns_base_load_hosts doesn't remove outdated addresses As mentioned at https://sourceforge.net/p/levent/bugs/293/ created a small function "evdns_base_flush_outdated_host_addresses" which removes all the previous host addresses, if user wants to clean up the list of hosts can call and use this function. Defination of this function is part of another patch. --- include/event2/dns.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/event2/dns.h b/include/event2/dns.h index edd2a23e..b7ca0937 100644 --- a/include/event2/dns.h +++ b/include/event2/dns.h @@ -237,6 +237,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); +/** + 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); + /** Convert a DNS error code to a string.