]> granicus.if.org Git - libevent/commitdiff
bug fix for issues #293 evdns_base_load_hosts doesn't remove outdated adresses
authorKuldeep Gupta <kuldeepjec@gmail.com>
Fri, 6 Dec 2013 11:23:16 +0000 (16:53 +0530)
committerKuldeep Gupta <kuldeepjec@gmail.com>
Fri, 6 Dec 2013 11:23:16 +0000 (16:53 +0530)
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

diff --git a/evdns.c b/evdns.c
index 66a3bff3b8b3fb0f38d662db85384b0f91a06b6c..04362a32615281e92f89bcd61d39ff275c90a690 100644 (file)
--- 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)
 {