From c8daa7bf866aa6c7f3b5c93fc7de5b3ae4cd12f9 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 3 Nov 2008 01:26:37 +0000 Subject: [PATCH] Add stats about when peers renew their announces. --- ot_mutex.h | 1 + ot_stats.c | 17 ++++++++++++++++- ot_stats.h | 1 + trackerlogic.c | 6 +++++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ot_mutex.h b/ot_mutex.h index c05bdfe..e16a097 100644 --- a/ot_mutex.h +++ b/ot_mutex.h @@ -28,6 +28,7 @@ typedef enum { TASK_STATS_VERSION = 0x000a, TASK_STATS_BUSY_NETWORKS = 0x000b, TASK_STATS_VECTOR_DEBUG = 0x000c, + TASK_STATS_RENEW = 0x000d, TASK_STATS = 0x0100, /* Mask */ TASK_STATS_TORRENTS = 0x0101, diff --git a/ot_stats.c b/ot_stats.c index 37eda5b..ddc3a15 100644 --- a/ot_stats.c +++ b/ot_stats.c @@ -46,6 +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 time_t ot_start_time; @@ -492,6 +493,15 @@ static size_t stats_httperrors_txt ( char * reply ) { ot_failed_request_counts[6] ); } +static size_t stats_return_renew_bucket( char * reply ) { + char *r = reply; + int i; + + for( i=0; ipeer_list->base < NOW ) + torrent->peer_list->base = NOW; } #endif @@ -125,6 +127,7 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM( case 1: default: torrent->peer_list->peer_count--; mutex_bucket_unlock_by_hash( hash ); + stats_issue_event( EVENT_RENEW, 0, i ); return torrent; } } @@ -142,6 +145,7 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM( if( OT_FLAG( peer_dest ) & PEER_FLAG_COMPLETED ) OT_FLAG( peer ) |= PEER_FLAG_COMPLETED; + stats_issue_event( EVENT_RENEW, 0, base_pool ); memmove( peer_dest, peer, sizeof( ot_peer ) ); } @@ -385,4 +389,4 @@ void trackerlogic_deinit( void ) { mutex_deinit( ); } -const char *g_version_trackerlogic_c = "$Source: /home/cvsroot/opentracker/trackerlogic.c,v $: $Revision: 1.107 $\n"; +const char *g_version_trackerlogic_c = "$Source: /home/cvsroot/opentracker/trackerlogic.c,v $: $Revision: 1.108 $\n";