]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
oom: Fix have_been_under_memory_pressure()
authorDavid Goulet <dgoulet@torproject.org>
Thu, 13 Nov 2025 15:09:25 +0000 (10:09 -0500)
committerDavid Goulet <dgoulet@torproject.org>
Thu, 13 Nov 2025 19:45:58 +0000 (14:45 -0500)
Well, this is simple, the function got in in 2014, was never used until now and
it was entirely wrong from the start.

This commit fixes it plain and simply.

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

index 01cb6beaa69f901246f1cc75890c8e76c9082a6e..e4e3eda17d4a766891d8dc26f20ed2cfcbac1b57 100644 (file)
@@ -2985,14 +2985,11 @@ cell_queues_check_size(void)
 
 /** Return true if we've been under memory pressure in the last
  * MEMORY_PRESSURE_INTERVAL seconds. */
-int
+bool
 have_been_under_memory_pressure(void)
 {
-  if (last_time_under_memory_pressure == 0) {
-    return false;
-  }
-  return last_time_under_memory_pressure + MEMORY_PRESSURE_INTERVAL
-    < approx_time();
+  return approx_time() <
+         last_time_under_memory_pressure + MEMORY_PRESSURE_INTERVAL;
 }
 
 /**
index 12198ae9827e77a70de7be74e206f03ad4fa3bd9..552c106674ef122c502dcf9837ff038fdda240e1 100644 (file)
@@ -62,7 +62,7 @@ extern uint64_t oom_stats_n_bytes_removed_hsdir;
 void dump_cell_pool_usage(int severity);
 size_t packed_cell_mem_cost(void);
 
-int have_been_under_memory_pressure(void);
+bool have_been_under_memory_pressure(void);
 
 /* For channeltls.c */
 void packed_cell_free_(packed_cell_t *cell);