From 6cbd21542cf7a751e6f0f38864e7e9eae8fa3b14 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 27 Oct 2026 21:32:24 +0100 Subject: Plug in the new per-thread stats counter, also make sure that the ot_clean sleep does not stall tracker exit --- trackerlogic.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'trackerlogic.c') diff --git a/trackerlogic.c b/trackerlogic.c index aac4448..477c4a6 100644 --- a/trackerlogic.c +++ b/trackerlogic.c @@ -149,16 +149,16 @@ size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstru peer_list->peer_count++; if (OT_PEERFLAG(ws->peer) & PEER_FLAG_COMPLETED) { peer_list->down_count++; - stats_issue_event(EVENT_COMPLETED, 0, (uintptr_t)ws); + stats_issue_event(ws, EVENT_COMPLETED, 0, 0); } if (OT_PEERFLAG(ws->peer) & PEER_FLAG_SEEDING) peer_list->seed_count++; } else { - stats_issue_event(EVENT_RENEW, 0, OT_PEERTIME(peer_dest, peer_size)); + stats_issue_event(ws, EVENT_RENEW, 0, OT_PEERTIME(peer_dest, peer_size)); #ifdef WANT_SPOT_WOODPECKER if ((OT_PEERTIME(peer_dest, peer_size) > 0) && (OT_PEERTIME(peer_dest, peer_size) < 20)) - stats_issue_event(EVENT_WOODPECKER, 0, (uintptr_t)&ws->peer); + stats_issue_event(ws, EVENT_WOODPECKER, 0, (uintptr_t)&ws->peer); #endif #ifdef WANT_SYNC_LIVE /* Won't live sync peers that come back too fast. Only exception: @@ -176,7 +176,7 @@ size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstru peer_list->seed_count++; if (!(OT_PEERFLAG_D(peer_dest, peer_size) & PEER_FLAG_COMPLETED) && (OT_PEERFLAG(ws->peer) & PEER_FLAG_COMPLETED)) { peer_list->down_count++; - stats_issue_event(EVENT_COMPLETED, 0, (uintptr_t)ws); + stats_issue_event(ws, EVENT_COMPLETED, 0, 0); } if (OT_PEERFLAG_D(peer_dest, peer_size) & PEER_FLAG_COMPLETED) OT_PEERFLAG(ws->peer) |= PEER_FLAG_COMPLETED; @@ -571,6 +571,13 @@ void trackerlogic_deinit(void) { int delta_torrentcount = 0; size_t bucket, j; + /* Stop the background workers first */ + stats_deinit(); + livesync_deinit(); + accesslist_deinit(); + fullscrape_deinit(); + clean_deinit(); + /* Free all torrents... */ for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) { ot_vector *torrents_list = mutex_bucket_lock(bucket); @@ -586,12 +593,6 @@ void trackerlogic_deinit(void) { mutex_bucket_unlock(bucket, delta_torrentcount); } - /* Deinitialise background worker threads */ - stats_deinit(); - livesync_deinit(); - accesslist_deinit(); - fullscrape_deinit(); - clean_deinit(); /* Release mutexes */ mutex_deinit(); } -- cgit v1.3