summaryrefslogtreecommitdiff
path: root/src/ot_clean.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-11-07 16:54:36 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-11-07 16:54:36 +0100
commit1e7248b330bde4c70528ccf91535391e19294dc3 (patch)
treef650bc5090227578602de43b3f1ea6dfa3c8e5b5 /src/ot_clean.c
parentcfbe53da5d9ef8dad1bb3276c0b33ec2ab6e974b (diff)
Add a knob to help reducing memory consumption. This time: empty torrents may expire sooner
Diffstat (limited to 'src/ot_clean.c')
-rw-r--r--src/ot_clean.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ot_clean.c b/src/ot_clean.c
index 77cb4ba..9e2186f 100644
--- a/src/ot_clean.c
+++ b/src/ot_clean.c
@@ -16,6 +16,8 @@
16#include "ot_vector.h" 16#include "ot_vector.h"
17#include "trackerlogic.h" 17#include "trackerlogic.h"
18 18
19ot_time g_empty_torrent_timeout = OT_TORRENT_TIMEOUT;
20
19/* Returns amount of removed peers */ 21/* Returns amount of removed peers */
20static ssize_t clean_single_bucket(ot_peer *peers, size_t peer_count, size_t peer_size, time_t timedout, size_t *removed_seeders) { 22static ssize_t clean_single_bucket(ot_peer *peers, size_t peer_count, size_t peer_size, time_t timedout, size_t *removed_seeders) {
21 ot_peer *last_peer, *insert_point; 23 ot_peer *last_peer, *insert_point;
@@ -106,7 +108,7 @@ int clean_single_torrent(ot_torrent *torrent) {
106 /* Already empty and nothing arrived before the peer timeout: keep it only 108 /* Already empty and nothing arrived before the peer timeout: keep it only
107 while a down count is worth remembering */ 109 while a down count is worth remembering */
108 if (timedout > OT_PEER_TIMEOUT && !torrent->peer_list6 && !torrent->peer_list4) 110 if (timedout > OT_PEER_TIMEOUT && !torrent->peer_list6 && !torrent->peer_list4)
109 return torrent->down_count ? 0 : 1; 111 return (torrent->down_count && timedout <= g_empty_torrent_timeout) ? 0 : 1;
110 112
111 /* Peers past the peer timeout are gone regardless, which caps how far the 113 /* Peers past the peer timeout are gone regardless, which caps how far the
112 lists are aged in this pass */ 114 lists are aged in this pass */