summaryrefslogtreecommitdiff
path: root/trackerlogic.c
diff options
context:
space:
mode:
authorerdgeist <>2009-03-04 14:35:21 +0000
committererdgeist <>2009-03-04 14:35:21 +0000
commit9297967f8523f1ac22bbac1823529b970a07cf56 (patch)
tree0a6bc2a2d3ac9d38e53079040c7057c779e30f15 /trackerlogic.c
parent72a1564ca14392cc2e1d044554c6e86a0eda9409 (diff)
Add a stat option the count bucket stalls
Add an iterator for all torrents. It's slower but for stats it's okay. Move some stats collection stuff to the new iterator. More to come. Start a "report all stats" page. Start fixing the code to identify "busy" networks. Add the concept of hosts allowed to proxy. Add a parser for the X-Forwarded-For: HTTP header. Clean up HTTP Header handling code. (Remove some left overs of now vanished sync code).
Diffstat (limited to 'trackerlogic.c')
-rw-r--r--trackerlogic.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index 249a2a0..8ebaa46 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -337,6 +337,23 @@ size_t remove_peer_from_torrent( ot_hash hash, ot_peer *peer, char *reply, PROTO
337 return reply_size; 337 return reply_size;
338} 338}
339 339
340void iterate_all_torrents( int (*for_each)( ot_torrent* torrent, uintptr_t data ), uintptr_t data ) {
341 int bucket;
342 size_t j;
343
344 for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) {
345 ot_vector *torrents_list = mutex_bucket_lock( bucket );
346 ot_torrent *torrents = (ot_torrent*)(torrents_list->data);
347
348 for( j=0; j<torrents_list->size; ++j )
349 if( for_each( torrents + j, data ) )
350 break;
351
352 mutex_bucket_unlock( bucket, 0 );
353 if( !g_opentracker_running ) return;
354 }
355}
356
340void exerr( char * message ) { 357void exerr( char * message ) {
341 fprintf( stderr, "%s\n", message ); 358 fprintf( stderr, "%s\n", message );
342 exit( 111 ); 359 exit( 111 );
@@ -358,7 +375,7 @@ void trackerlogic_init( ) {
358void trackerlogic_deinit( void ) { 375void trackerlogic_deinit( void ) {
359 int bucket, delta_torrentcount = 0; 376 int bucket, delta_torrentcount = 0;
360 size_t j; 377 size_t j;
361 378
362 /* Free all torrents... */ 379 /* Free all torrents... */
363 for(bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) { 380 for(bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) {
364 ot_vector *torrents_list = mutex_bucket_lock( bucket ); 381 ot_vector *torrents_list = mutex_bucket_lock( bucket );