diff options
| author | erdgeist <> | 2007-04-03 11:08:17 +0000 |
|---|---|---|
| committer | erdgeist <> | 2007-04-03 11:08:17 +0000 |
| commit | 5c18293c9c7b2c5f419135b1705f07460e7773b0 (patch) | |
| tree | 6f86e247b14fdd03d23d0bbefc7277ca939db9d7 /trackerlogic.c | |
| parent | bd4617a911fb961c5251425fff3e531e3968867c (diff) | |
New Makefile, incorporated some patches sent to me by Robin H. Johnson
Diffstat (limited to 'trackerlogic.c')
| -rw-r--r-- | trackerlogic.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index 5bda0df..bdf120f 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
| @@ -243,9 +243,9 @@ size_t return_peers_for_torrent( ot_torrent *torrent, size_t amount, char *reply | |||
| 243 | if( is_tcp ) | 243 | if( is_tcp ) |
| 244 | r += sprintf( r, "d8:completei%zde10:incompletei%zde8:intervali%ie5:peers%zd:", seed_count, peer_count-seed_count, OT_CLIENT_REQUEST_INTERVAL_RANDOM, 6*amount ); | 244 | r += sprintf( r, "d8:completei%zde10:incompletei%zde8:intervali%ie5:peers%zd:", seed_count, peer_count-seed_count, OT_CLIENT_REQUEST_INTERVAL_RANDOM, 6*amount ); |
| 245 | else { | 245 | else { |
| 246 | *(unsigned long*)(r+0) = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); | 246 | *(ot_dword*)(r+0) = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); |
| 247 | *(unsigned long*)(r+4) = htonl( peer_count ); | 247 | *(ot_dword*)(r+4) = htonl( peer_count ); |
| 248 | *(unsigned long*)(r+8) = htonl( seed_count ); | 248 | *(ot_dword*)(r+8) = htonl( seed_count ); |
| 249 | r += 12; | 249 | r += 12; |
| 250 | } | 250 | } |
| 251 | 251 | ||
| @@ -357,7 +357,7 @@ size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ) { | |||
| 357 | if( !exactmatch ) { | 357 | if( !exactmatch ) { |
| 358 | memset( reply, 0, 12); | 358 | memset( reply, 0, 12); |
| 359 | } else { | 359 | } else { |
| 360 | unsigned long *r = (unsigned long*) reply; | 360 | ot_dword *r = (ot_dword*) reply; |
| 361 | 361 | ||
| 362 | for( i=0; i<OT_POOLS_COUNT; ++i ) { | 362 | for( i=0; i<OT_POOLS_COUNT; ++i ) { |
| 363 | peers += torrent->peer_list->peers[i].size; | 363 | peers += torrent->peer_list->peers[i].size; |
| @@ -394,7 +394,7 @@ size_t return_tcp_scrape_for_torrent( ot_hash *hash, char *reply ) { | |||
| 394 | /* Throw away old changeset */ | 394 | /* Throw away old changeset */ |
| 395 | static void release_changeset( void ) { | 395 | static void release_changeset( void ) { |
| 396 | ot_byte **changeset_ptrs = (ot_byte**)(changeset.data); | 396 | ot_byte **changeset_ptrs = (ot_byte**)(changeset.data); |
| 397 | int i; | 397 | size_t i; |
| 398 | 398 | ||
| 399 | for( i = 0; i < changeset.size; ++i ) | 399 | for( i = 0; i < changeset.size; ++i ) |
| 400 | free( changeset_ptrs[i] ); | 400 | free( changeset_ptrs[i] ); |
| @@ -507,7 +507,8 @@ size_t return_changeset_for_tracker( char **reply ) { | |||
| 507 | /* Clean up all torrents, remove timedout pools and | 507 | /* Clean up all torrents, remove timedout pools and |
| 508 | torrents, also prepare new changeset */ | 508 | torrents, also prepare new changeset */ |
| 509 | void clean_all_torrents( void ) { | 509 | void clean_all_torrents( void ) { |
| 510 | int i, j, k; | 510 | int i, k; |
| 511 | size_t j; | ||
| 511 | time_t time_now = NOW; | 512 | time_t time_now = NOW; |
| 512 | size_t peers_count; | 513 | size_t peers_count; |
| 513 | 514 | ||
| @@ -566,7 +567,7 @@ void clean_all_torrents( void ) { | |||
| 566 | } | 567 | } |
| 567 | } | 568 | } |
| 568 | 569 | ||
| 569 | typedef struct { int val; ot_torrent * torrent; } ot_record; | 570 | typedef struct { size_t val; ot_torrent * torrent; } ot_record; |
| 570 | 571 | ||
| 571 | /* Fetches stats from tracker */ | 572 | /* Fetches stats from tracker */ |
| 572 | size_t return_stats_for_tracker( char *reply, int mode ) { | 573 | size_t return_stats_for_tracker( char *reply, int mode ) { |
| @@ -611,11 +612,11 @@ size_t return_stats_for_tracker( char *reply, int mode ) { | |||
| 611 | r += sprintf( r, "Top5 torrents by peers:\n" ); | 612 | r += sprintf( r, "Top5 torrents by peers:\n" ); |
| 612 | for( idx=0; idx<5; ++idx ) | 613 | for( idx=0; idx<5; ++idx ) |
| 613 | if( top5c[idx].torrent ) | 614 | if( top5c[idx].torrent ) |
| 614 | r += sprintf( r, "\t%i\t%s\n", top5c[idx].val, to_hex(top5c[idx].torrent->hash) ); | 615 | r += sprintf( r, "\t%zd\t%s\n", top5c[idx].val, to_hex(top5c[idx].torrent->hash) ); |
| 615 | r += sprintf( r, "Top5 torrents by seeds:\n" ); | 616 | r += sprintf( r, "Top5 torrents by seeds:\n" ); |
| 616 | for( idx=0; idx<5; ++idx ) | 617 | for( idx=0; idx<5; ++idx ) |
| 617 | if( top5s[idx].torrent ) | 618 | if( top5s[idx].torrent ) |
| 618 | r += sprintf( r, "\t%i\t%s\n", top5s[idx].val, to_hex(top5s[idx].torrent->hash) ); | 619 | r += sprintf( r, "\t%zd\t%s\n", top5s[idx].val, to_hex(top5s[idx].torrent->hash) ); |
| 619 | } else { | 620 | } else { |
| 620 | r += sprintf( r, "%zd\n%zd\nopentracker serving %zd torrents\nopentracker", peer_count, seed_count, torrent_count ); | 621 | r += sprintf( r, "%zd\n%zd\nopentracker serving %zd torrents\nopentracker", peer_count, seed_count, torrent_count ); |
| 621 | } | 622 | } |
