From d620e4c3ea42b0df6eb5e8dab92d7a8f031fa617 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Thu, 5 Nov 2026 13:59:14 +0100 Subject: Take the clock off the wall --- src/trackerlogic.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/trackerlogic.c') diff --git a/src/trackerlogic.c b/src/trackerlogic.c index 8e30a48..60d5b18 100644 --- a/src/trackerlogic.c +++ b/src/trackerlogic.c @@ -38,10 +38,17 @@ void free_peerlist(ot_peerlist *peer_list) { free(peer_list); } -void add_torrent_from_saved_state(ot_hash const hash, ot_time base, size_t down_count) { +/* How many minutes before this moment the torrent was last touched, which is + what a state dump records. */ +void add_torrent_from_saved_state(ot_hash const hash, ot_time age, size_t down_count) { int exactmatch; ot_torrent *torrent; - ot_vector *torrents_list = mutex_bucket_lock_by_hash(hash); + ot_vector *torrents_list; + + if (age > OT_TORRENT_TIMEOUT) + return; + + torrents_list = mutex_bucket_lock_by_hash(hash); if (!accesslist_hashisvalid(hash)) { mutex_bucket_unlock_by_hash(hash, 0); @@ -66,8 +73,8 @@ void add_torrent_from_saved_state(ot_hash const hash, ot_time base, size_t down_ memset(torrent->peer_list6, 0, sizeof(ot_peerlist)); memset(torrent->peer_list4, 0, sizeof(ot_peerlist)); - torrent->peer_list6->base = base; - torrent->peer_list4->base = base; + torrent->peer_list6->base = time_now_minutes() - age; + torrent->peer_list4->base = time_now_minutes() - age; torrent->peer_list6->down_count = down_count; torrent->peer_list4->down_count = down_count; -- cgit v1.3