diff --git a/libtransmission/tracker.c b/libtransmission/tracker.c index 3d8c6cfe5..199b043ad 100644 --- a/libtransmission/tracker.c +++ b/libtransmission/tracker.c @@ -246,7 +246,7 @@ escape( char * out, const uint8_t * in, int in_len ) /* rfc2396 */ *out = '\0'; } -static void scrapeNow( tr_tracker * ); +static int onScrapeNow( void * vt ); tr_tracker * tr_trackerNew( const tr_torrent * torrent ) @@ -301,7 +301,13 @@ tr_trackerNew( const tr_torrent * torrent ) assert( nwalk - t->addresses == sum ); assert( iwalk - t->tierFronts == sum ); - scrapeNow( t ); + /* scrape sometime in the next two minutes. + scrapes are staggered out like this to prevent + hundreds of scrapes from going out at the same time */ + t->scrapeTimer = tr_timerNew( t->handle, + onScrapeNow, t, + tr_rand(120)*1000 ); + return t; } @@ -487,9 +493,6 @@ findTrackerFromHash( struct torrent_hash * data ) **** ***/ -static int -onScrapeNow( void * vt ); - static void onScrapeResponse( struct evhttp_request * req, void * vhash ) { @@ -599,12 +602,6 @@ onScrapeNow( void * vt ) return FALSE; } -static void -scrapeNow( tr_tracker * t ) -{ - onScrapeNow( t ); -} - /*** **** **** TRACKER REQUESTS diff --git a/libtransmission/utils.h b/libtransmission/utils.h index 18e3d809e..2070216ab 100644 --- a/libtransmission/utils.h +++ b/libtransmission/utils.h @@ -40,7 +40,7 @@ FILE* tr_getLog( void ); char* tr_getLogTimeStr( char * buf, int buflen ); -int tr_rand ( int ); +int tr_rand ( int ); int tr_mkdirp( const char * path, int permissions );