summaryrefslogtreecommitdiff
path: root/trackerlogic.c
diff options
context:
space:
mode:
Diffstat (limited to 'trackerlogic.c')
-rw-r--r--trackerlogic.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index 1f38f07..477c4a6 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -117,8 +117,8 @@ size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstru
117 } else 117 } else
118 clean_single_torrent(torrent); 118 clean_single_torrent(torrent);
119 119
120 torrent->peer_list6->base = g_now_minutes; 120 torrent->peer_list6->base = time_now_minutes();
121 torrent->peer_list4->base = g_now_minutes; 121 torrent->peer_list4->base = time_now_minutes();
122 122
123 peer_list = peer_size == OT_PEER_SIZE6 ? torrent->peer_list6 : torrent->peer_list4; 123 peer_list = peer_size == OT_PEER_SIZE6 ? torrent->peer_list6 : torrent->peer_list4;
124 124
@@ -149,16 +149,16 @@ size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstru
149 peer_list->peer_count++; 149 peer_list->peer_count++;
150 if (OT_PEERFLAG(ws->peer) & PEER_FLAG_COMPLETED) { 150 if (OT_PEERFLAG(ws->peer) & PEER_FLAG_COMPLETED) {
151 peer_list->down_count++; 151 peer_list->down_count++;
152 stats_issue_event(EVENT_COMPLETED, 0, (uintptr_t)ws); 152 stats_issue_event(ws, EVENT_COMPLETED, 0, 0);
153 } 153 }
154 if (OT_PEERFLAG(ws->peer) & PEER_FLAG_SEEDING) 154 if (OT_PEERFLAG(ws->peer) & PEER_FLAG_SEEDING)
155 peer_list->seed_count++; 155 peer_list->seed_count++;
156 156
157 } else { 157 } else {
158 stats_issue_event(EVENT_RENEW, 0, OT_PEERTIME(peer_dest, peer_size)); 158 stats_issue_event(ws, EVENT_RENEW, 0, OT_PEERTIME(peer_dest, peer_size));
159#ifdef WANT_SPOT_WOODPECKER 159#ifdef WANT_SPOT_WOODPECKER
160 if ((OT_PEERTIME(peer_dest, peer_size) > 0) && (OT_PEERTIME(peer_dest, peer_size) < 20)) 160 if ((OT_PEERTIME(peer_dest, peer_size) > 0) && (OT_PEERTIME(peer_dest, peer_size) < 20))
161 stats_issue_event(EVENT_WOODPECKER, 0, (uintptr_t)&ws->peer); 161 stats_issue_event(ws, EVENT_WOODPECKER, 0, (uintptr_t)&ws->peer);
162#endif 162#endif
163#ifdef WANT_SYNC_LIVE 163#ifdef WANT_SYNC_LIVE
164 /* Won't live sync peers that come back too fast. Only exception: 164 /* 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
176 peer_list->seed_count++; 176 peer_list->seed_count++;
177 if (!(OT_PEERFLAG_D(peer_dest, peer_size) & PEER_FLAG_COMPLETED) && (OT_PEERFLAG(ws->peer) & PEER_FLAG_COMPLETED)) { 177 if (!(OT_PEERFLAG_D(peer_dest, peer_size) & PEER_FLAG_COMPLETED) && (OT_PEERFLAG(ws->peer) & PEER_FLAG_COMPLETED)) {
178 peer_list->down_count++; 178 peer_list->down_count++;
179 stats_issue_event(EVENT_COMPLETED, 0, (uintptr_t)ws); 179 stats_issue_event(ws, EVENT_COMPLETED, 0, 0);
180 } 180 }
181 if (OT_PEERFLAG_D(peer_dest, peer_size) & PEER_FLAG_COMPLETED) 181 if (OT_PEERFLAG_D(peer_dest, peer_size) & PEER_FLAG_COMPLETED)
182 OT_PEERFLAG(ws->peer) |= PEER_FLAG_COMPLETED; 182 OT_PEERFLAG(ws->peer) |= PEER_FLAG_COMPLETED;
@@ -571,6 +571,13 @@ void trackerlogic_deinit(void) {
571 int delta_torrentcount = 0; 571 int delta_torrentcount = 0;
572 size_t bucket, j; 572 size_t bucket, j;
573 573
574 /* Stop the background workers first */
575 stats_deinit();
576 livesync_deinit();
577 accesslist_deinit();
578 fullscrape_deinit();
579 clean_deinit();
580
574 /* Free all torrents... */ 581 /* Free all torrents... */
575 for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) { 582 for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) {
576 ot_vector *torrents_list = mutex_bucket_lock(bucket); 583 ot_vector *torrents_list = mutex_bucket_lock(bucket);
@@ -586,12 +593,6 @@ void trackerlogic_deinit(void) {
586 mutex_bucket_unlock(bucket, delta_torrentcount); 593 mutex_bucket_unlock(bucket, delta_torrentcount);
587 } 594 }
588 595
589 /* Deinitialise background worker threads */
590 stats_deinit();
591 livesync_deinit();
592 accesslist_deinit();
593 fullscrape_deinit();
594 clean_deinit();
595 /* Release mutexes */ 596 /* Release mutexes */
596 mutex_deinit(); 597 mutex_deinit();
597} 598}