summaryrefslogtreecommitdiff
path: root/trackerlogic.c
diff options
context:
space:
mode:
Diffstat (limited to 'trackerlogic.c')
-rw-r--r--trackerlogic.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index c57d1a9..5d83abb 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -110,7 +110,22 @@ int vector_remove_torrent( ot_vector vector, ot_hash *hash ) {
110} 110}
111 111
112void clean_peerlist( ot_peerlist peer_list ) { 112void clean_peerlist( ot_peerlist peer_list ) {
113 exit( 1 ); 113 long timedout = NOW-peer_list->base;
114 int i;
115
116 if( !timedout ) return;
117 if( timedout > OT_POOLS_COUNT ) timedout = OT_POOLS_COUNT;
118
119 for( i=OT_POOLS_COUNT-timedout; i<OT_POOLS_COUNT; ++i )
120 free( peer_list->peers[i].data);
121
122 MEMMOVE( peer_list->peers + timedout, peer_list->peers, sizeof( ot_vector ) * (OT_POOLS_COUNT-timedout) );
123 byte_zero( peer_list->peers, sizeof( ot_vector ) * timedout );
124
125 MEMMOVE( peer_list->seed_count + timedout, peer_list->seed_count, sizeof( unsigned long ) * (OT_POOLS_COUNT-timedout) );
126 byte_zero( peer_list->seed_count, sizeof( unsigned long ) * timedout );
127
128 peer_list->base = NOW;
114} 129}
115 130
116ot_torrent add_peer_to_torrent( ot_hash *hash, ot_peer peer ) { 131ot_torrent add_peer_to_torrent( ot_hash *hash, ot_peer peer ) {