summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ot_mutex.h1
-rw-r--r--ot_stats.c15
-rw-r--r--ot_stats.h1
-rw-r--r--trackerlogic.c4
4 files changed, 21 insertions, 0 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 {
28 TASK_STATS_VERSION = 0x000a, 28 TASK_STATS_VERSION = 0x000a,
29 TASK_STATS_BUSY_NETWORKS = 0x000b, 29 TASK_STATS_BUSY_NETWORKS = 0x000b,
30 TASK_STATS_VECTOR_DEBUG = 0x000c, 30 TASK_STATS_VECTOR_DEBUG = 0x000c,
31 TASK_STATS_RENEW = 0x000d,
31 32
32 TASK_STATS = 0x0100, /* Mask */ 33 TASK_STATS = 0x0100, /* Mask */
33 TASK_STATS_TORRENTS = 0x0101, 34 TASK_STATS_TORRENTS = 0x0101,
diff --git a/ot_stats.c b/ot_stats.c
index 5d9dab2..5427f1f 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -46,6 +46,7 @@ static unsigned long long ot_full_scrape_count = 0;
46static unsigned long long ot_full_scrape_request_count = 0; 46static unsigned long long ot_full_scrape_request_count = 0;
47static unsigned long long ot_full_scrape_size = 0; 47static unsigned long long ot_full_scrape_size = 0;
48static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT]; 48static unsigned long long ot_failed_request_counts[CODE_HTTPERROR_COUNT];
49static unsigned long long ot_renewed[OT_POOLS_COUNT];
49 50
50static time_t ot_start_time; 51static time_t ot_start_time;
51 52
@@ -492,6 +493,15 @@ static size_t stats_httperrors_txt ( char * reply ) {
492 ot_failed_request_counts[6] ); 493 ot_failed_request_counts[6] );
493} 494}
494 495
496static size_t stats_return_renew_bucket( char * reply ) {
497 char *r = reply;
498 int i;
499
500 for( i=0; i<OT_BUCKET_COUNT; ++i )
501 r+=sprintf(r,"%02i %llu\n", i, ot_renewed[i] );
502 return r - reply;
503}
504
495extern const char 505extern const char
496*g_version_opentracker_c, *g_version_accesslist_c, *g_version_clean_c, *g_version_fullscrape_c, *g_version_http_c, 506*g_version_opentracker_c, *g_version_accesslist_c, *g_version_clean_c, *g_version_fullscrape_c, *g_version_http_c,
497*g_version_iovec_c, *g_version_mutex_c, *g_version_stats_c, *g_version_sync_c, *g_version_udp_c, *g_version_vector_c, 507*g_version_iovec_c, *g_version_mutex_c, *g_version_stats_c, *g_version_sync_c, *g_version_udp_c, *g_version_vector_c,
@@ -525,6 +535,8 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) {
525 return stats_httperrors_txt( reply ); 535 return stats_httperrors_txt( reply );
526 case TASK_STATS_VERSION: 536 case TASK_STATS_VERSION:
527 return stats_return_tracker_version( reply ); 537 return stats_return_tracker_version( reply );
538 case TASK_STATS_RENEW:
539 return stats_return_renew_bucket( reply );
528#ifdef WANT_LOG_NETWORKS 540#ifdef WANT_LOG_NETWORKS
529 case TASK_STATS_BUSY_NETWORKS: 541 case TASK_STATS_BUSY_NETWORKS:
530 return stats_return_busy_networks( reply ); 542 return stats_return_busy_networks( reply );
@@ -596,6 +608,9 @@ void stats_issue_event( ot_status_event event, PROTO_FLAG proto, uint32_t event_
596 case EVENT_FAILED: 608 case EVENT_FAILED:
597 ot_failed_request_counts[event_data]++; 609 ot_failed_request_counts[event_data]++;
598 break; 610 break;
611 case EVENT_RENEW:
612 ot_renewed[event_data]++;
613 break;
599 case EVENT_SYNC_IN_REQUEST: 614 case EVENT_SYNC_IN_REQUEST:
600 case EVENT_SYNC_IN: 615 case EVENT_SYNC_IN:
601 case EVENT_SYNC_OUT_REQUEST: 616 case EVENT_SYNC_OUT_REQUEST:
diff --git a/ot_stats.h b/ot_stats.h
index a21251b..76fdcb5 100644
--- a/ot_stats.h
+++ b/ot_stats.h
@@ -11,6 +11,7 @@ typedef enum {
11 EVENT_READ, 11 EVENT_READ,
12 EVENT_CONNECT, /* UDP only */ 12 EVENT_CONNECT, /* UDP only */
13 EVENT_ANNOUNCE, 13 EVENT_ANNOUNCE,
14 EVENT_RENEW,
14 EVENT_SCRAPE, 15 EVENT_SCRAPE,
15 EVENT_FULLSCRAPE_REQUEST, 16 EVENT_FULLSCRAPE_REQUEST,
16 EVENT_FULLSCRAPE_REQUEST_GZIP, 17 EVENT_FULLSCRAPE_REQUEST_GZIP,
diff --git a/trackerlogic.c b/trackerlogic.c
index 3d9ca5e..0aca287 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -91,6 +91,8 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM(
91 return torrent; 91 return torrent;
92 } 92 }
93 base_pool = 1; 93 base_pool = 1;
94 if( torrent->peer_list->base < NOW )
95 torrent->peer_list->base = NOW;
94 } 96 }
95#endif 97#endif
96 98
@@ -125,6 +127,7 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM(
125 case 1: default: 127 case 1: default:
126 torrent->peer_list->peer_count--; 128 torrent->peer_list->peer_count--;
127 mutex_bucket_unlock_by_hash( hash ); 129 mutex_bucket_unlock_by_hash( hash );
130 stats_issue_event( EVENT_RENEW, 0, i );
128 return torrent; 131 return torrent;
129 } 132 }
130 } 133 }
@@ -142,6 +145,7 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM(
142 if( OT_FLAG( peer_dest ) & PEER_FLAG_COMPLETED ) 145 if( OT_FLAG( peer_dest ) & PEER_FLAG_COMPLETED )
143 OT_FLAG( peer ) |= PEER_FLAG_COMPLETED; 146 OT_FLAG( peer ) |= PEER_FLAG_COMPLETED;
144 147
148 stats_issue_event( EVENT_RENEW, 0, base_pool );
145 memmove( peer_dest, peer, sizeof( ot_peer ) ); 149 memmove( peer_dest, peer, sizeof( ot_peer ) );
146 } 150 }
147 151