summaryrefslogtreecommitdiff
path: root/ot_stats.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_stats.c')
-rw-r--r--ot_stats.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/ot_stats.c b/ot_stats.c
index a4596c6..dbab275 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -187,7 +187,7 @@ size_t stats_top10_txt( char * reply ) {
187 top10s[idx].torrent = (ot_torrent*)(torrents_list->data) + j; 187 top10s[idx].torrent = (ot_torrent*)(torrents_list->data) + j;
188 } 188 }
189 } 189 }
190 mutex_bucket_unlock( bucket ); 190 mutex_bucket_unlock( bucket, 0 );
191 if( !g_opentracker_running ) 191 if( !g_opentracker_running )
192 return 0; 192 return 0;
193 } 193 }
@@ -241,7 +241,7 @@ static size_t stats_slash24s_txt( char * reply, size_t amount, uint32_t thresh )
241 if( !count ) { 241 if( !count ) {
242 count = malloc( sizeof(uint32_t) * NUM_S24S ); 242 count = malloc( sizeof(uint32_t) * NUM_S24S );
243 if( !count ) { 243 if( !count ) {
244 mutex_bucket_unlock( bucket ); 244 mutex_bucket_unlock( bucket, 0 );
245 goto bailout_cleanup; 245 goto bailout_cleanup;
246 } 246 }
247 byte_zero( count, sizeof( uint32_t ) * NUM_S24S ); 247 byte_zero( count, sizeof( uint32_t ) * NUM_S24S );
@@ -251,7 +251,7 @@ static size_t stats_slash24s_txt( char * reply, size_t amount, uint32_t thresh )
251 } 251 }
252 } 252 }
253 } 253 }
254 mutex_bucket_unlock( bucket ); 254 mutex_bucket_unlock( bucket, 0 );
255 if( !g_opentracker_running ) 255 if( !g_opentracker_running )
256 goto bailout_cleanup; 256 goto bailout_cleanup;
257 } 257 }
@@ -384,7 +384,7 @@ static size_t stats_peers_mrtg( char * reply ) {
384 ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list; 384 ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list;
385 peer_count += peer_list->peer_count; seed_count += peer_list->seed_count; 385 peer_count += peer_list->peer_count; seed_count += peer_list->seed_count;
386 } 386 }
387 mutex_bucket_unlock( bucket ); 387 mutex_bucket_unlock( bucket, 0 );
388 if( !g_opentracker_running ) 388 if( !g_opentracker_running )
389 return 0; 389 return 0;
390 } 390 }
@@ -397,17 +397,7 @@ static size_t stats_peers_mrtg( char * reply ) {
397 397
398static size_t stats_startstop_mrtg( char * reply ) 398static size_t stats_startstop_mrtg( char * reply )
399{ 399{
400 size_t torrent_count = 0; 400 size_t torrent_count = mutex_get_torrent_count();
401 int bucket;
402
403 for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket )
404 {
405 ot_vector *torrents_list = mutex_bucket_lock( bucket );
406 torrent_count += torrents_list->size;
407 mutex_bucket_unlock( bucket );
408 if( !g_opentracker_running )
409 return 0;
410 }
411 401
412 return sprintf( reply, "%zd\n%zd\nopentracker handling %zd torrents\nopentracker", 402 return sprintf( reply, "%zd\n%zd\nopentracker handling %zd torrents\nopentracker",
413 (size_t)0, 403 (size_t)0,
@@ -429,7 +419,7 @@ static size_t stats_toraddrem_mrtg( char * reply )
429 ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list; 419 ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list;
430 peer_count += peer_list->peer_count; 420 peer_count += peer_list->peer_count;
431 } 421 }
432 mutex_bucket_unlock( bucket ); 422 mutex_bucket_unlock( bucket, 0 );
433 if( !g_opentracker_running ) 423 if( !g_opentracker_running )
434 return 0; 424 return 0;
435 } 425 }
@@ -443,15 +433,7 @@ static size_t stats_toraddrem_mrtg( char * reply )
443 433
444static size_t stats_torrents_mrtg( char * reply ) 434static size_t stats_torrents_mrtg( char * reply )
445{ 435{
446 size_t torrent_count = 0; 436 size_t torrent_count = mutex_get_torrent_count();
447 int bucket;
448
449 for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket )
450 {
451 ot_vector *torrents_list = mutex_bucket_lock( bucket );
452 torrent_count += torrents_list->size;
453 mutex_bucket_unlock( bucket );
454 }
455 437
456 return sprintf( reply, "%zd\n%zd\nopentracker serving %zd torrents\nopentracker", 438 return sprintf( reply, "%zd\n%zd\nopentracker serving %zd torrents\nopentracker",
457 torrent_count, 439 torrent_count,