]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
OOM-purge the DNS cache one part at a time
authorNick Mathewson <nickm@torproject.org>
Fri, 17 May 2019 14:03:41 +0000 (10:03 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 17 May 2019 14:03:41 +0000 (10:03 -0400)
Previously we purged it in 1-hour increments -- but one-hour is the
maximum TTL for the cache!  Now we do it in 25%-TTL increments.

Fixes bug 29617; bugfix on 0.3.5.1-alpha.

changes/ticket29617 [new file with mode: 0644]
src/feature/relay/dns.c

diff --git a/changes/ticket29617 b/changes/ticket29617
new file mode 100644 (file)
index 0000000..4d50ea9
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes (out-of-memory handler):
+    - When purging the DNS cache because of an out-of-memory condition,
+      try purging just the older entries at first.  Previously, we would
+      purge the whole thing. Fixes bug 29617; bugfix on 0.3.5.1-alpha.
index d3660c47ef8fda19f6bc9cabbcece5c91e6fbb15..cc9f4cf49003a0e2458e223f874c5f1d0b74410f 100644 (file)
@@ -2130,7 +2130,8 @@ dns_cache_handle_oom(time_t now, size_t min_remove_bytes)
     current_size -= bytes_removed;
     total_bytes_removed += bytes_removed;
 
-    time_inc += 3600; /* Increase time_inc by 1 hour. */
+    /* Increase time_inc by a reasonable fraction. */
+    time_inc += (MAX_DNS_TTL_AT_EXIT / 4);
   } while (total_bytes_removed < min_remove_bytes);
 
   return total_bytes_removed;