]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge remote-tracking branch 'dgoulet/ticket24902_029_05'
authorNick Mathewson <nickm@torproject.org>
Fri, 2 Feb 2018 20:00:35 +0000 (15:00 -0500)
committerNick Mathewson <nickm@torproject.org>
Fri, 2 Feb 2018 20:00:35 +0000 (15:00 -0500)
1  2 
src/or/geoip.c
src/or/geoip.h
src/or/relay.c
src/test/test.c

diff --cc src/or/geoip.c
index 5b954979b94cf1c42e13758a176f82ed5c76a67a,20dad5f1597aceb7afc2417e0619677a39acd34f..15871f0d2f7f56107c14590a6ddf0d795bb46637
@@@ -510,12 -541,18 +542,21 @@@ HT_PROTOTYPE(clientmap, clientmap_entry
  HT_GENERATE2(clientmap, clientmap_entry_t, node, clientmap_entry_hash,
               clientmap_entries_eq, 0.6, tor_reallocarray_, tor_free_)
  
 +#define clientmap_entry_free(ent) \
 +  FREE_AND_NULL(clientmap_entry_t, clientmap_entry_free_, ent)
 +
+ /** Return the size of a client map entry. */
+ static inline size_t
+ clientmap_entry_size(const clientmap_entry_t *ent)
+ {
+   tor_assert(ent);
+   return (sizeof(clientmap_entry_t) +
+           (ent->transport_name ? strlen(ent->transport_name) : 0));
+ }
  /** Free all storage held by <b>ent</b>. */
  static void
 -clientmap_entry_free(clientmap_entry_t *ent)
 +clientmap_entry_free_(clientmap_entry_t *ent)
  {
    if (!ent)
      return;
diff --cc src/or/geoip.h
Simple merge
diff --cc src/or/relay.c
index b1b99526dff089367848e05bf0ebbd51a9d7f279,22ce7675238bae2c35d06d563bb4db827921191e..506b7eccb3401f445861b1c5bdd9afa42f3f9917
@@@ -2613,11 -2469,15 +2613,15 @@@ static time_t last_time_under_memory_pr
  STATIC int
  cell_queues_check_size(void)
  {
+   time_t now = time(NULL);
    size_t alloc = cell_queues_get_total_allocation();
    alloc += buf_get_total_allocation();
 -  alloc += tor_zlib_get_total_allocation();
 +  alloc += tor_compress_get_total_allocation();
    const size_t rend_cache_total = rend_cache_get_total_allocation();
    alloc += rend_cache_total;
+   const size_t geoip_client_cache_total =
+     geoip_client_cache_total_allocation();
+   alloc += geoip_client_cache_total;
    if (alloc >= get_options()->MaxMemInQueues_low_threshold) {
      last_time_under_memory_pressure = approx_time();
      if (alloc >= get_options()->MaxMemInQueues) {
        if (rend_cache_total > get_options()->MaxMemInQueues / 5) {
          const size_t bytes_to_remove =
            rend_cache_total - (size_t)(get_options()->MaxMemInQueues / 10);
-         alloc -= hs_cache_handle_oom(time(NULL), bytes_to_remove);
 -        rend_cache_clean_v2_descs_as_dir(now, bytes_to_remove);
 -        alloc -= rend_cache_total;
 -        alloc += rend_cache_get_total_allocation();
++        alloc -= hs_cache_handle_oom(now, bytes_to_remove);
+       }
+       if (geoip_client_cache_total > get_options()->MaxMemInQueues / 5) {
+         const size_t bytes_to_remove =
+           geoip_client_cache_total -
+           (size_t)(get_options()->MaxMemInQueues / 10);
+         alloc -= geoip_client_cache_handle_oom(now, bytes_to_remove);
        }
        circuits_handle_oom(alloc);
        return 1;
diff --cc src/test/test.c
Simple merge