[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r9386: Free CACHE_STATE_DONE cached_router_t items on dns_free_all( (in tor/trunk: . src/or)



Author: nickm
Date: 2007-01-22 14:13:02 -0500 (Mon, 22 Jan 2007)
New Revision: 9386

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/dns.c
Log:
 r9718@catbus:  nickm | 2007-01-22 14:13:00 -0500
 Free CACHE_STATE_DONE cached_router_t items on dns_free_all().



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r9718] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-01-22 07:51:06 UTC (rev 9385)
+++ tor/trunk/ChangeLog	2007-01-22 19:13:02 UTC (rev 9386)
@@ -51,6 +51,8 @@
       bytes.)
     - Fix as-yet-unused reverse IPv6 lookup code so it sends nybbles in the
       correct order.
+    - Free memory held in recently-completed DNS lookup attempts on exit.
+      This was not a memory leak, but may have been hiding memory leaks.
 
 
 Changes in version 0.1.2.6-alpha - 2007-01-09

Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c	2007-01-22 07:51:06 UTC (rev 9385)
+++ tor/trunk/src/or/dns.c	2007-01-22 19:13:02 UTC (rev 9386)
@@ -318,6 +318,21 @@
 dns_free_all(void)
 {
   cached_resolve_t **ptr, **next, *item;
+  if (cached_resolve_pqueue) {
+    SMARTLIST_FOREACH(cached_resolve_pqueue, cached_resolve_t *, res,
+      {
+        /* XXXX012 The hach lookups here could be quite slow; remove them
+         * once we're happy. */
+        if (res->state == CACHE_STATE_DONE) {
+          cached_resolve_t *removed = HT_REMOVE(cache_map, &cache_root, res);
+          tor_assert(!removed);
+          _free_cached_resolve(res);
+        } else {
+          cached_resolve_t *found = HT_FIND(cache_map, &cache_root, res);
+          tor_assert(found);
+        }
+      });
+  }
   for (ptr = HT_START(cache_map, &cache_root); ptr != NULL; ptr = next) {
     item = *ptr;
     next = HT_NEXT_RMV(cache_map, &cache_root, ptr);