diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-02-11 01:26:47 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-02-11 01:26:47 +0000 |
commit | f672577bc6d32ecfe96582b463a83cac8eaac66f (patch) | |
tree | 03999d6f3338a1383cea660189cad8f6fcdf08b2 /src/or/dns.c | |
parent | 60f234f42b63ed6a5208c70bbc4c32e532cc903d (diff) | |
download | tor-f672577bc6d32ecfe96582b463a83cac8eaac66f.tar.gz tor-f672577bc6d32ecfe96582b463a83cac8eaac66f.zip |
Free even more things on shutdown. Temporarily move tor_free_all out from #ifdef so it gets tested more.
svn:r3614
Diffstat (limited to 'src/or/dns.c')
-rw-r--r-- | src/or/dns.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/or/dns.c b/src/or/dns.c index 7b23f60ea9..71dff34009 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -99,6 +99,27 @@ void dns_init(void) { spawn_enough_dnsworkers(); } +static void +_free_cached_resolve(struct cached_resolve *r) { + while(r->pending_connections) { + struct pending_connection_t *victim = r->pending_connections; + r->pending_connections = victim->next; + tor_free(victim); + } + tor_free(r); +} + +void +dns_free_all(void) +{ + struct cached_resolve *ptr, *next; + for (ptr = SPLAY_MIN(cache_tree, &cache_root); ptr != NULL; ptr = next) { + next = SPLAY_NEXT(cache_tree, &cache_root, ptr); + SPLAY_REMOVE(cache_tree, &cache_root, ptr); + _free_cached_resolve(ptr); + } +} + /** Linked list of resolved addresses, oldest to newest. */ static struct cached_resolve *oldest_cached_resolve = NULL; static struct cached_resolve *newest_cached_resolve = NULL; |