]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
geoip: Make geoip_client_cache_total_allocation() return the counter
authorDavid Goulet <dgoulet@torproject.org>
Mon, 5 Feb 2018 15:39:10 +0000 (10:39 -0500)
committerDavid Goulet <dgoulet@torproject.org>
Mon, 5 Feb 2018 18:38:55 +0000 (13:38 -0500)
The HT_FOREACH() is insanely heavy on the CPU and this is part of the fast
path so make it return the nice memory size counter we added in
4d812e29b9b1ec88.

Fixes #25148

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/or/geoip.c

index 20dad5f1597aceb7afc2417e0619677a39acd34f..a39366ed1332cc80512e31a98787b204d3d135da 100644 (file)
@@ -769,13 +769,7 @@ geoip_client_cache_handle_oom(time_t now, size_t min_remove_bytes)
 size_t
 geoip_client_cache_total_allocation(void)
 {
-  size_t bytes = 0;
-  clientmap_entry_t **ent;
-
-  HT_FOREACH(ent, clientmap, &client_history) {
-    bytes += clientmap_entry_size(*ent);
-  }
-  return bytes;
+  return geoip_client_history_cache_size;
 }
 
 /** How many responses are we giving to clients requesting v3 network