Changeset 12297


Ignore:
Timestamp:
Apr 2, 2011, 7:44:19 AM (11 years ago)
Author:
jordan
Message:

(trunk libT) better multiscrape

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r12283 r12297  
    295295tr_tier;
    296296
     297static time_t
     298get_next_scrape_time( int interval )
     299{
     300    const time_t now = tr_time( );
     301
     302    /* Add the interval, and then increment to the nearest 10th second.
     303     * The latter step is to increas the odds of several torrents coming
     304     * due at the same time to improve multiscrape. */
     305    return (now+interval) + (10-((now+interval)%10));
     306}
     307
    297308static void
    298309tierConstruct( tr_tier * tier, tr_torrent * tor )
    299310{
    300311    static int nextKey = 1;
    301     const time_t now = tr_time( );
    302312
    303313    memset( tier, 0, sizeof( tr_tier ) );
     
    308318    tier->announceIntervalSec = DEFAULT_ANNOUNCE_INTERVAL_SEC;
    309319    tier->announceMinIntervalSec = DEFAULT_ANNOUNCE_MIN_INTERVAL_SEC;
    310     tier->scrapeAt = now + tr_cryptoWeakRandInt( 60*3 );
     320    tier->scrapeAt = get_next_scrape_time( tr_cryptoWeakRandInt( 180 ) );
    311321    tier->tor = tor;
    312322}
     
    10691079
    10701080            tier->isRunning = data->isRunningOnSuccess;
    1071             tier->scrapeAt = now + tier->scrapeIntervalSec;
     1081            tier->scrapeAt = get_next_scrape_time( tier->scrapeIntervalSec );
    10721082            tier->lastScrapeTime = now;
    10731083            tier->lastScrapeSucceeded = true;
     
    11751185    dbgmsg( tier, "Retrying scrape in %d seconds.", interval );
    11761186    tier->lastScrapeSucceeded = false;
    1177     tier->scrapeAt = tr_time() + interval;
     1187    tier->scrapeAt = get_next_scrape_time( interval );
    11781188}
    11791189
     
    12551265                    tier->scrapeIntervalSec = MAX( DEFAULT_SCRAPE_INTERVAL_SEC,
    12561266                                                   response->min_request_interval );
    1257                     tier->scrapeAt = now + tier->scrapeIntervalSec;
     1267                    tier->scrapeAt = get_next_scrape_time( tier->scrapeIntervalSec );
    12581268                    tr_tordbg( tier->tor, "Scrape successful. Rescraping in %d seconds.",
    12591269                               tier->scrapeIntervalSec );
Note: See TracChangeset for help on using the changeset viewer.