diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-09-25 20:38:58 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-09-25 20:38:58 +0000 |
commit | 01f9e97d43014f9d404d9b09031bed814ac507a3 (patch) | |
tree | db85785b5cf8f31f58220907a39edf2a3c949b6c /src/or/eventdns.c | |
parent | 52e179b942f48383a76ae102133a66e939a64862 (diff) | |
download | tor-01f9e97d43014f9d404d9b09031bed814ac507a3.tar.gz tor-01f9e97d43014f9d404d9b09031bed814ac507a3.zip |
Minor fix: add code to eventdns so it can free memory on shutdown. This should help valgrind and dmalloc freak out less.
svn:r8503
Diffstat (limited to 'src/or/eventdns.c')
-rw-r--r-- | src/or/eventdns.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/or/eventdns.c b/src/or/eventdns.c index ea1305a4f9..c41065818b 100644 --- a/src/or/eventdns.c +++ b/src/or/eventdns.c @@ -2294,7 +2294,7 @@ main(int c, char **v) { } int -evdns_init() +evdns_init(void) { int res = 0; #ifdef MS_WINDOWS @@ -2308,6 +2308,45 @@ evdns_init() #endif +void +evdns_shutdown(int fail_requests) +{ + struct nameserver *server, *server_next; + struct search_domain *dom, *dom_next; + + while (req_head) { + if (fail_requests) + reply_callback(req_head, 0, DNS_ERR_SHUTDOWN, NULL); + request_finished(req_head, &req_head); + } + while (req_waiting_head) { + if (fail_requests) + reply_callback(req_waiting_head, 0, DNS_ERR_SHUTDOWN, NULL); + request_finished(req_waiting_head, &req_waiting_head); + } + global_requests_inflight = global_requests_waiting = 0; + + for (server = server_head; server; server = server_next) { + server_next = server->next; + if (server->socket >= 0) + CLOSE_SOCKET(server->socket); + (void) event_del(&server->event); + free(server); + } + server_head = NULL; + global_good_nameservers = 0; + + if (global_search_state) { + for (dom = global_search_state->head; dom; dom = dom_next) { + dom_next = dom->next; + free(dom); + } + free(global_search_state); + global_search_state = NULL; + } + evdns_log_fn = NULL; +} + // Local Variables: // tab-width: 4 // c-basic-offset: 4 |