summaryrefslogtreecommitdiff
path: root/src/ot_fullscrape.c
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 /src/ot_fullscrape.c
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 'src/ot_fullscrape.c')
-rw-r--r--src/ot_fullscrape.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/ot_fullscrape.c b/src/ot_fullscrape.c
index 52ec480..9fae444 100644
--- a/src/ot_fullscrape.c
+++ b/src/ot_fullscrape.c
@@ -90,9 +90,9 @@ static void fullscrape_write_one( ot_tasktype mode, char **cursor, ot_torrent *t
90 exactly that size */ 90 exactly that size */
91 char *r = *cursor; 91 char *r = *cursor;
92 const char *r_end = r + OT_SCRAPE_MAXENTRYLEN; 92 const char *r_end = r + OT_SCRAPE_MAXENTRYLEN;
93 size_t seed_count = torrent->peer_list6->seed_count + torrent->peer_list4->seed_count; 93 size_t seed_count = peerlist_seed_count(torrent->peer_list6) + peerlist_seed_count(torrent->peer_list4);
94 size_t peer_count = torrent->peer_list6->peer_count + torrent->peer_list4->peer_count; 94 size_t peer_count = peerlist_peer_count(torrent->peer_list6) + peerlist_peer_count(torrent->peer_list4);
95 size_t down_count = torrent->peer_list6->down_count + torrent->peer_list4->down_count; 95 size_t down_count = torrent->down_count;
96 96
97 switch (mode & TASK_TASK_MASK) { 97 switch (mode & TASK_TASK_MASK) {
98 case TASK_FULLSCRAPE: 98 case TASK_FULLSCRAPE:
@@ -131,7 +131,7 @@ static void fullscrape_write_one( ot_tasktype mode, char **cursor, ot_torrent *t
131 case TASK_FULLSCRAPE_TRACKERSTATE: 131 case TASK_FULLSCRAPE_TRACKERSTATE:
132 hex_from_hash(r, *hash); 132 hex_from_hash(r, *hash);
133 r += 2 * sizeof(ot_hash); 133 r += 2 * sizeof(ot_hash);
134 fmt_append(&r, r_end, ":%zd:%zd\n", (ssize_t)(time_wall_minutes() - time_since_minutes(torrent->peer_list6->base)), down_count); 134 fmt_append(&r, r_end, ":%zd:%zd\n", (ssize_t)(time_wall_minutes() - time_since_minutes(torrent->base)), down_count);
135 break; 135 break;
136 } 136 }
137 *cursor = r; 137 *cursor = r;