return random check back intervals to our clients

dynamic-accesslists
erdgeist 18 years ago
parent 2f0658a3af
commit dffea5da69

@ -26,9 +26,6 @@
#include "trackerlogic.h" #include "trackerlogic.h"
#include "scan_urlencoded_query.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_connections = 0;
static unsigned int ot_overall_successfulannounces = 0; static unsigned int ot_overall_successfulannounces = 0;
static time_t ot_start_time; static time_t ot_start_time;
@ -346,7 +343,7 @@ e400_param:
if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) { if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) {
remove_peer_from_torrent( hash, &peer ); 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 { } else {
torrent = add_peer_to_torrent( hash, &peer ); torrent = add_peer_to_torrent( hash, &peer );
if( !torrent ) { if( !torrent ) {
@ -511,7 +508,7 @@ void handle_accept( int64 serversocket ) {
while( ( i = socket_accept4( serversocket, (char*)ip, &port) ) != -1 ) { while( ( i = socket_accept4( serversocket, (char*)ip, &port) ) != -1 ) {
if( !io_fd( i ) || 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 ); io_close( i );
continue; continue;
} }

@ -253,7 +253,7 @@ size_t return_peers_for_torrent( ot_torrent *torrent, unsigned int amount, char
} }
if( peer_count < amount ) amount = peer_count; 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 ) { if( amount ) {
unsigned int pool_offset, pool_index = 0;; unsigned int pool_offset, pool_index = 0;;
unsigned int shifted_pc = peer_count; unsigned int shifted_pc = peer_count;

@ -18,6 +18,14 @@ typedef ot_byte ot_hash[20];
typedef ot_dword ot_ip; typedef ot_dword ot_ip;
typedef time_t ot_time; 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 /* We maintain a list of 256 pointers to sorted list of ot_torrent structs
Sort key is, of course, its hash */ Sort key is, of course, its hash */

Loading…
Cancel
Save