tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit d9547b120cd45059925451f99cce5133f57f7f5d
parent 699f085b911149dce05333b96130f5c9f941d081
Author: David Goulet <dgoulet@torproject.org>
Date:   Thu, 13 Nov 2025 10:09:25 -0500

oom: Fix have_been_under_memory_pressure()

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>

Diffstat:
Msrc/core/or/relay.c | 9+++------
Msrc/core/or/relay.h | 2+-
2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/core/or/relay.c b/src/core/or/relay.c @@ -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; } /** diff --git a/src/core/or/relay.h b/src/core/or/relay.h @@ -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);