Changeset 5601


Ignore:
Timestamp:
Apr 12, 2008, 10:37:03 PM (14 years ago)
Author:
charles
Message:

#765: for every consecutive scrape failure, wait longer before trying again.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/tracker.c

    r5585 r5601  
    8181    int announceMinIntervalSec;
    8282    int scrapeIntervalSec;
     83    int retryScrapeIntervalSec;
    8384
    8485    tr_tracker_info * redirect;
     
    564565{
    565566    int tryAgain;
    566     time_t nextScrapeSec = 60;
     567    int responseCode;
    567568    struct torrent_hash * torrent_hash = (struct torrent_hash*) vhash;
    568569    tr_tracker * t = findTrackerFromHash( torrent_hash );
     
    620621                         t->scrapeIntervalSec );
    621622
    622                 nextScrapeSec = t->scrapeIntervalSec;
     623                t->retryScrapeIntervalSec = 30;
    623624            }
    624625        }
     
    630631    updateAddresses( t, req, &tryAgain );
    631632
    632     if( tryAgain )
    633         t->scrapeAt = time( NULL );
     633    /**
     634    ***
     635    **/
     636
     637    if( tryAgain )
     638        responseCode = 300;
     639    else if( req )
     640        responseCode = req->response_code;
    634641    else
    635         t->scrapeAt = time( NULL ) + t->randOffset + nextScrapeSec;
     642        responseCode = 503;
     643
     644    if( 200<=responseCode && responseCode<=299 )
     645    {
     646        const int interval = t->scrapeIntervalSec + t->randOffset;
     647        dbgmsg( t, "request succeeded. rescraping in %d seconds", interval );
     648        t->scrapeAt = time( NULL ) + interval;
     649    }
     650    else if( 300<=responseCode && responseCode<=399 )
     651    {
     652        const int interval = 5;
     653        dbgmsg( t, "got a redirect. retrying in %d seconds", interval );
     654        t->scrapeAt = time( NULL ) + interval;
     655    }
     656    else
     657    {
     658        const int interval = t->retryScrapeIntervalSec + t->randOffset;
     659        dbgmsg( t, "Tracker responded to scrape with %d.  Retrying in %d seconds.", responseCode,  interval );
     660        t->retryScrapeIntervalSec *= 2;
     661        t->scrapeAt = time( NULL ) + interval;
     662    }
    636663}
    637664
     
    10421069    t->handle = torrent->handle;
    10431070    t->scrapeIntervalSec       = DEFAULT_SCRAPE_INTERVAL_SEC;
     1071    t->retryScrapeIntervalSec  = 60;
    10441072    t->announceIntervalSec     = DEFAULT_ANNOUNCE_INTERVAL_SEC;
    10451073    t->announceMinIntervalSec  = DEFAULT_ANNOUNCE_MIN_INTERVAL_SEC;
Note: See TracChangeset for help on using the changeset viewer.