summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opentracker.c7
-rw-r--r--trackerlogic.c2
-rw-r--r--trackerlogic.h8
3 files changed, 11 insertions, 6 deletions
diff --git a/opentracker.c b/opentracker.c
index eea02eb..403fa21 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -26,9 +26,6 @@
26#include "trackerlogic.h" 26#include "trackerlogic.h"
27#include "scan_urlencoded_query.h" 27#include "scan_urlencoded_query.h"
28 28
29unsigned int const OT_CLIENT_TIMEOUT = 30;
30unsigned int const OT_CLIENT_TIMEOUT_CHECKINTERVAL = 5;
31
32static unsigned int ot_overall_connections = 0; 29static unsigned int ot_overall_connections = 0;
33static unsigned int ot_overall_successfulannounces = 0; 30static unsigned int ot_overall_successfulannounces = 0;
34static time_t ot_start_time; 31static time_t ot_start_time;
@@ -346,7 +343,7 @@ e400_param:
346 343
347 if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) { 344 if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) {
348 remove_peer_from_torrent( hash, &peer ); 345 remove_peer_from_torrent( hash, &peer );
349 memmove( static_scratch + SUCCESS_HTTP_HEADER_LENGTH, "d8:completei0e10:incompletei0e8:intervali1800e5:peers0:e", reply_size = 56 ); 346 reply_size = sprintf( static_scratch + SUCCESS_HTTP_HEADER_LENGTH, "d8:completei0e10:incompletei0e8:intervali%ie5:peers0:e", OT_CLIENT_REQUEST_INTERVAL_RANDOM );
350 } else { 347 } else {
351 torrent = add_peer_to_torrent( hash, &peer ); 348 torrent = add_peer_to_torrent( hash, &peer );
352 if( !torrent ) { 349 if( !torrent ) {
@@ -511,7 +508,7 @@ void handle_accept( int64 serversocket ) {
511 while( ( i = socket_accept4( serversocket, (char*)ip, &port) ) != -1 ) { 508 while( ( i = socket_accept4( serversocket, (char*)ip, &port) ) != -1 ) {
512 509
513 if( !io_fd( i ) || 510 if( !io_fd( i ) ||
514 !( h = (struct http_data*)malloc( sizeof struct http_data ) ) ) { 511 !( h = (struct http_data*)malloc( sizeof( struct http_data ) ) ) ) {
515 io_close( i ); 512 io_close( i );
516 continue; 513 continue;
517 } 514 }
diff --git a/trackerlogic.c b/trackerlogic.c
index ea9b929..4de5038 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -253,7 +253,7 @@ size_t return_peers_for_torrent( ot_torrent *torrent, unsigned int amount, char
253 } 253 }
254 if( peer_count < amount ) amount = peer_count; 254 if( peer_count < amount ) amount = peer_count;
255 255
256 r += sprintf( r, "d8:completei%ie10:incompletei%ie8:intervali1800e5:peers%i:", seed_count, peer_count-seed_count, 6*amount ); 256 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 );
257 if( amount ) { 257 if( amount ) {
258 unsigned int pool_offset, pool_index = 0;; 258 unsigned int pool_offset, pool_index = 0;;
259 unsigned int shifted_pc = peer_count; 259 unsigned int shifted_pc = peer_count;
diff --git a/trackerlogic.h b/trackerlogic.h
index b047d7d..8a61b74 100644
--- a/trackerlogic.h
+++ b/trackerlogic.h
@@ -18,6 +18,14 @@ typedef ot_byte ot_hash[20];
18typedef ot_dword ot_ip; 18typedef ot_dword ot_ip;
19typedef time_t ot_time; 19typedef time_t ot_time;
20 20
21/* Some tracker behaviour tunable */
22#define OT_CLIENT_TIMEOUT 30
23#define OT_CLIENT_TIMEOUT_CHECKINTERVAL 5
24#define OT_CLIENT_REQUEST_INTERVAL 1800
25#define OT_CLIENT_REQUEST_VARIATION 180
26
27#define OT_CLIENT_REQUEST_INTERVAL_RANDOM ( OT_CLIENT_REQUEST_INTERVAL + (int)( random( ) % OT_CLIENT_REQUEST_VARIATION ) )
28
21/* We maintain a list of 256 pointers to sorted list of ot_torrent structs 29/* We maintain a list of 256 pointers to sorted list of ot_torrent structs
22 Sort key is, of course, its hash */ 30 Sort key is, of course, its hash */
23 31