diff options
author | erdgeist <> | 2007-02-01 13:51:40 +0000 |
---|---|---|
committer | erdgeist <> | 2007-02-01 13:51:40 +0000 |
commit | f9c49e9759e279408b1928dc681cc9d6a91778e5 (patch) | |
tree | ddb056a84456600e7a2e8b330f0c1c98eb2d7aa3 /trackerlogic.c | |
parent | 62c59983cb3122ec20183efb27b1a9e9e454971d (diff) |
el cheapo vector debugging
Diffstat (limited to 'trackerlogic.c')
-rw-r--r-- | trackerlogic.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index f4c61d3..54f236f 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -24,7 +24,6 @@ | |||
24 | 24 | ||
25 | /* GLOBAL VARIABLES */ | 25 | /* GLOBAL VARIABLES */ |
26 | static ot_vector all_torrents[256]; | 26 | static ot_vector all_torrents[256]; |
27 | |||
28 | #ifdef WANT_CLOSED_TRACKER | 27 | #ifdef WANT_CLOSED_TRACKER |
29 | int g_closedtracker = 1; | 28 | int g_closedtracker = 1; |
30 | static ot_torrent* const OT_TORRENT_NOT_ON_WHITELIST = (ot_torrent*)1; | 29 | static ot_torrent* const OT_TORRENT_NOT_ON_WHITELIST = (ot_torrent*)1; |
@@ -329,6 +328,37 @@ size_t return_fullscrape_for_tracker( char **reply ) { | |||
329 | return r - *reply; | 328 | return r - *reply; |
330 | } | 329 | } |
331 | 330 | ||
331 | size_t return_memstat_for_tracker( char **reply ) { | ||
332 | size_t torrent_count = 0, j; | ||
333 | int i, k; | ||
334 | char *r; | ||
335 | time_t time_now = NOW; | ||
336 | |||
337 | for( i=0; i<256; ++i ) { | ||
338 | ot_vector *torrents_list = &all_torrents[i]; | ||
339 | torrent_count += torrents_list->size; | ||
340 | } | ||
341 | |||
342 | if( !( r = *reply = malloc( 256*32 + 64*torrent_count ) ) ) return 0; | ||
343 | |||
344 | for( i=0; i<256; ++i ) | ||
345 | r += sprintf( r, "%02X: %08X %08X\n", i, (ot_dword)all_torrents[i].size, (ot_dword)all_torrents[i].space ); | ||
346 | |||
347 | for( i=0; i<256; ++i ) { | ||
348 | ot_vector *torrents_list = &all_torrents[i]; | ||
349 | for( j=0; j<torrents_list->size; ++j ) { | ||
350 | ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list; | ||
351 | ot_hash *hash =&( ((ot_torrent*)(torrents_list->data))[j] ).hash; | ||
352 | r += sprintf( r, "\n%s:\n", to_hex( (ot_byte*)hash ) ); | ||
353 | clean_peerlist( time_now, peer_list ); | ||
354 | for( k=0; k<OT_POOLS_COUNT; ++k ) | ||
355 | r += sprintf( r, "\t%08X %08X\n", peer_list->peers[k].size, peer_list->peers[k].space ); | ||
356 | } | ||
357 | } | ||
358 | |||
359 | return r - *reply; | ||
360 | } | ||
361 | |||
332 | /* Fetches scrape info for a specific torrent */ | 362 | /* Fetches scrape info for a specific torrent */ |
333 | size_t return_scrape_for_torrent( ot_hash *hash, char *reply ) { | 363 | size_t return_scrape_for_torrent( ot_hash *hash, char *reply ) { |
334 | char *r = reply; | 364 | char *r = reply; |