Browse Source

Removed the 'total_cells_allocated' global counter

This could have been made atomic, but the gcc version on one of
the servers is too old for C11 atomics, so just removed it instead.
Steven Engler 4 years ago
parent
commit
f2035c1ffa
2 changed files with 15 additions and 13 deletions
  1. 2 2
      src/core/or/circuitlist.c
  2. 13 11
      src/core/or/relay.c

+ 2 - 2
src/core/or/circuitlist.c

@@ -2673,14 +2673,14 @@ circuits_handle_oom(size_t current_allocation)
   uint32_t now_ts;
   log_notice(LD_GENERAL, "We're low on memory (cell queues total alloc:"
              //" %"TOR_PRIuSZ" buffer total alloc: %" TOR_PRIuSZ ","
-             " %"TOR_PRIuSZ" buffer total alloc: <unknown>,"
+             " <unknown> buffer total alloc: <unknown>,"
              " tor compress total alloc: %" TOR_PRIuSZ
              " (zlib: %" TOR_PRIuSZ ", zstd: %" TOR_PRIuSZ ","
              " lzma: %" TOR_PRIuSZ "),"
              " rendezvous cache total alloc: %" TOR_PRIuSZ "). Killing"
              " circuits withover-long queues. (This behavior is controlled by"
              " MaxMemInQueues.)",
-             cell_queues_get_total_allocation(),
+             //cell_queues_get_total_allocation(),
              //buf_get_total_allocation(),
              tor_compress_get_total_allocation(),
              tor_zlib_get_total_allocation(),

+ 13 - 11
src/core/or/relay.c

@@ -2488,13 +2488,13 @@ circuit_consider_stop_edge_reading(circuit_t *circ, crypt_path_t *layer_hint)
 }
 
 /** The total number of cells we have allocated. */
-static size_t total_cells_allocated = 0;
+//static size_t total_cells_allocated = 0;
 
 /** Release storage held by <b>cell</b>. */
 static inline void
 packed_cell_free_unchecked(packed_cell_t *cell)
 {
-  --total_cells_allocated;
+  //--total_cells_allocated;
   tor_free(cell);
 }
 
@@ -2502,7 +2502,7 @@ packed_cell_free_unchecked(packed_cell_t *cell)
 STATIC packed_cell_t *
 packed_cell_new(void)
 {
-  ++total_cells_allocated;
+  //++total_cells_allocated;
   return tor_malloc_zero(sizeof(packed_cell_t));
 }
 
@@ -2530,8 +2530,9 @@ dump_cell_pool_usage(int severity)
   }
   SMARTLIST_FOREACH_END(c);
   tor_log(severity, LD_MM,
-          "%d cells allocated on %d circuits. %d cells leaked.",
-          n_cells, n_circs, (int)total_cells_allocated - n_cells);
+          "%d cells allocated on %d circuits.", n_cells, n_circs);
+  //        "%d cells allocated on %d circuits. %d cells leaked.",
+  //        n_cells, n_circs, (int)total_cells_allocated - n_cells);
 }
 
 /** Allocate a new copy of packed <b>cell</b>. */
@@ -2679,11 +2680,11 @@ packed_cell_mem_cost(void)
 }
 
 /* DOCDOC */
-size_t
-cell_queues_get_total_allocation(void)
-{
-  return total_cells_allocated * packed_cell_mem_cost();
-}
+//size_t
+//cell_queues_get_total_allocation(void)
+//{
+//  return total_cells_allocated * packed_cell_mem_cost();
+//}
 
 /** How long after we've been low on memory should we try to conserve it? */
 #define MEMORY_PRESSURE_INTERVAL (30*60)
@@ -2697,7 +2698,8 @@ STATIC int
 cell_queues_check_size(void)
 {
   time_t now = time(NULL);
-  size_t alloc = cell_queues_get_total_allocation();
+  //size_t alloc = cell_queues_get_total_allocation();
+  size_t alloc = 0;
   alloc += half_streams_get_total_allocation();
   //alloc += buf_get_total_allocation();
   alloc += tor_compress_get_total_allocation();