From 334c6e4bbb97a4c0656e1b07c3e6a565f68eae2b Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Fri, 28 Nov 2008 22:21:10 +0000 Subject: The BIG refactoring [tm]. Too many changes to count them. If it doesn't suite you, revert to last version. --- ot_stats.c | 71 +++++++++++--------------------------------------------------- 1 file changed, 12 insertions(+), 59 deletions(-) (limited to 'ot_stats.c') diff --git a/ot_stats.c b/ot_stats.c index 0751bf8..2428adf 100644 --- a/ot_stats.c +++ b/ot_stats.c @@ -46,7 +46,7 @@ static unsigned long long ot_full_scrape_count = 0; static unsigned long long ot_full_scrape_request_count = 0; static unsigned long long ot_full_scrape_size = 0; static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT]; -static unsigned long long ot_renewed[OT_POOLS_COUNT]; +static unsigned long long ot_renewed[OT_PEER_TIMEOUT]; static time_t ot_start_time; @@ -214,7 +214,7 @@ static size_t stats_slash24s_txt( char * reply, size_t amount, uint32_t thresh ) uint32_t *counts[ NUM_BUFS ]; uint32_t slash24s[amount*2]; /* first dword amount, second dword subnet */ - int bucket; +// int bucket; size_t i, j, k, l; char *r = reply; @@ -223,6 +223,8 @@ static size_t stats_slash24s_txt( char * reply, size_t amount, uint32_t thresh ) r += sprintf( r, "Stats for all /24s with more than %u announced torrents:\n\n", thresh ); +#if 0 + /* XXX: TOOD: Doesn't work yet with new peer storage model */ for( bucket=0; bucketsize; ++j ) { @@ -248,6 +250,7 @@ static size_t stats_slash24s_txt( char * reply, size_t amount, uint32_t thresh ) } mutex_bucket_unlock( bucket ); } +#endif k = l = 0; /* Debug: count allocated bufs */ for( i=0; i < NUM_BUFS; ++i ) { @@ -283,8 +286,6 @@ static size_t stats_slash24s_txt( char * reply, size_t amount, uint32_t thresh ) return r - reply; -bailout_cleanup: - for( i=0; i < NUM_BUFS; ++i ) free( counts[i] ); @@ -299,44 +300,6 @@ bailout_cleanup: } */ -static ssize_t stats_vector_usage( char * reply ) { - size_t i, j, *vec_member; - char *r = reply; - int exactmatch, bucket; - - ot_vector bucketsizes; - memset( &bucketsizes, 0, sizeof( bucketsizes )); - - for( bucket=0; bucketsize; ++i ) { - ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[i] ).peer_list; - for( j=0; jpeers[j].size, 3 * sizeof( size_t ), 2 * sizeof(size_t), &exactmatch) ) ) { - mutex_bucket_unlock( bucket ); - return 0; - } - if( !exactmatch ) { - vec_member[0] = peer_list->peers[j].size; - vec_member[1] = peer_list->peers[j].space; - vec_member[2] = 1; - } else - ++vec_member[2]; - } - } - mutex_bucket_unlock( bucket ); - } - - for( i = 0; i OT_STATS_TMPSIZE - 3*10+3 /* 3*%zd + 2*\t + \n */ ) - break; - } - - return r - reply; -} - static unsigned long events_per_time( unsigned long long events, time_t t ) { return events / ( (unsigned int)t ? (unsigned int)t : 1 ); } @@ -497,20 +460,20 @@ static size_t stats_return_renew_bucket( char * reply ) { char *r = reply; int i; - for( i=0; i