Browse Source

return random check back intervals to our clients

master
Dirk Engling 15 years ago
parent
commit
0f85392889
  1. 7
      opentracker.c
  2. 2
      trackerlogic.c
  3. 8
      trackerlogic.h

7
opentracker.c

@ -26,9 +26,6 @@
#include "trackerlogic.h"
#include "scan_urlencoded_query.h"
unsigned int const OT_CLIENT_TIMEOUT = 30;
unsigned int const OT_CLIENT_TIMEOUT_CHECKINTERVAL = 5;
static unsigned int ot_overall_connections = 0;
static unsigned int ot_overall_successfulannounces = 0;
static time_t ot_start_time;
@ -346,7 +343,7 @@ e400_param:
if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) {
remove_peer_from_torrent( hash, &peer );
memmove( static_scratch + SUCCESS_HTTP_HEADER_LENGTH, "d8:completei0e10:incompletei0e8:intervali1800e5:peers0:e", reply_size = 56 );
reply_size = sprintf( static_scratch + SUCCESS_HTTP_HEADER_LENGTH, "d8:completei0e10:incompletei0e8:intervali%ie5:peers0:e", OT_CLIENT_REQUEST_INTERVAL_RANDOM );
} else {
torrent = add_peer_to_torrent( hash, &peer );
if( !torrent ) {
@ -511,7 +508,7 @@ void handle_accept( int64 serversocket ) {
while( ( i = socket_accept4( serversocket, (char*)ip, &port) ) != -1 ) {
if( !io_fd( i ) ||
!( h = (struct http_data*)malloc( sizeof struct http_data ) ) ) {
!( h = (struct http_data*)malloc( sizeof( struct http_data ) ) ) ) {
io_close( i );
continue;
}

2
trackerlogic.c

@ -253,7 +253,7 @@ size_t return_peers_for_torrent( ot_torrent *torrent, unsigned int amount, char
}
if( peer_count < amount ) amount = peer_count;
r += sprintf( r, "d8:completei%ie10:incompletei%ie8:intervali1800e5:peers%i:", seed_count, peer_count-seed_count, 6*amount );
r += sprintf( r, "d8:completei%ie10:incompletei%ie8:intervali%ie5:peers%i:", seed_count, peer_count-seed_count, OT_CLIENT_REQUEST_INTERVAL_RANDOM, 6*amount );
if( amount ) {
unsigned int pool_offset, pool_index = 0;;
unsigned int shifted_pc = peer_count;

8
trackerlogic.h

@ -18,6 +18,14 @@ typedef ot_byte ot_hash[20];
typedef ot_dword ot_ip;
typedef time_t ot_time;
/* Some tracker behaviour tunable */
#define OT_CLIENT_TIMEOUT 30
#define OT_CLIENT_TIMEOUT_CHECKINTERVAL 5
#define OT_CLIENT_REQUEST_INTERVAL 1800
#define OT_CLIENT_REQUEST_VARIATION 180
#define OT_CLIENT_REQUEST_INTERVAL_RANDOM ( OT_CLIENT_REQUEST_INTERVAL + (int)( random( ) % OT_CLIENT_REQUEST_VARIATION ) )
/* We maintain a list of 256 pointers to sorted list of ot_torrent structs
Sort key is, of course, its hash */

Loading…
Cancel
Save