summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-11-07 03:55:27 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-11-07 03:55:27 +0100
commitbbfd674e08c6b1fa4081f9c678fd220bead749d7 (patch)
tree41c279103efda2765217a26c8164817d3db96606 /tests
parentf18339a50eed09ed47b2b22212d2a50e543e9b09 (diff)
Start to opentracker's memory requirements
* peer lists for v4 and v6 are now lazily allocated and, more importantly, will be freed once there are no more peers * The downloaded count is now per torrent and not per peer list anymore, moving in what was alignment loss, anyway * The (now) per torrent downloaded and the per peer list peer and seed count shrunk from size_t to uint32_t * A helper guards accesses to the peer and seed count to prevent null pointer dereferences * The base time also shrank from time_t to uint32_t, minutes since the epoch currently fits in 25 bits
Diffstat (limited to 'tests')
-rw-r--r--tests/t_clean.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/tests/t_clean.c b/tests/t_clean.c
index 7eca9aa..2fadd03 100644
--- a/tests/t_clean.c
+++ b/tests/t_clean.c
@@ -11,7 +11,7 @@
11#include "trackerlogic.h" 11#include "trackerlogic.h"
12#include "test.h" 12#include "test.h"
13 13
14/* A clock stepped backwards used to leave peer_list->base in the future, so 14/* A clock stepped backwards used to leave the torrent's base in the future, so
15 the span the cleaner works from came out negative. It was then added to a 15 the span the cleaner works from came out negative. It was then added to a
16 peer's age and stored in the single byte that age lives in, where -1 reads 16 peer's age and stored in the single byte that age lives in, where -1 reads
17 as 255 and the next pass threw the whole swarm away. */ 17 as 255 and the next pass threw the whole swarm away. */
@@ -60,14 +60,12 @@ static ot_torrent *torrent_of(ot_hash *hash) {
60 60
61/* What a clock stepped back by `minutes` leaves behind */ 61/* What a clock stepped back by `minutes` leaves behind */
62static void step_clock_back(ot_torrent *torrent, int minutes) { 62static void step_clock_back(ot_torrent *torrent, int minutes) {
63 torrent->peer_list6->base += minutes; 63 torrent->base += minutes;
64 torrent->peer_list4->base += minutes;
65} 64}
66 65
67/* What the next minute of a well behaved clock looks like */ 66/* What the next minute of a well behaved clock looks like */
68static void age_by_a_minute(ot_torrent *torrent) { 67static void age_by_a_minute(ot_torrent *torrent) {
69 torrent->peer_list6->base -= 1; 68 torrent->base -= 1;
70 torrent->peer_list4->base -= 1;
71} 69}
72 70
73static void case_a_clock_that_went_back_keeps_the_swarm(void) { 71static void case_a_clock_that_went_back_keeps_the_swarm(void) {