Changeset 10095


Ignore:
Timestamp:
Feb 5, 2010, 1:16:30 AM (12 years ago)
Author:
charles
Message:

(trunk libT) #2854 "tracker did not respond" -- when both scrapes and announces are vying for a turn, give announces a higher priority

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r10090 r10095  
    5757    KEYLEN = 8,
    5858
    59     /* how many scrapes we allow at one time */
    60     MAX_CONCURRENT_SCRAPES = 48,
    61 
    62     /* how many announces we allow at one time */
    63     MAX_CONCURRENT_ANNOUNCES = 48,
     59    /* how many web tasks we allow at one time */
     60    MAX_CONCURRENT_TASKS = 48,
    6461
    6562    /* if a tracker takes more than this long to respond,
     
    206203    tr_session * session;
    207204    struct event * upkeepTimer;
    208     int announceSlotsAvailable;
    209     int scrapeSlotsAvailable;
     205    int slotsAvailable;
    210206}
    211207tr_announcer;
     
    214210tr_announcerHasBacklog( const struct tr_announcer * announcer )
    215211{
    216     return ( announcer->scrapeSlotsAvailable < 1 )
    217         || ( announcer->announceSlotsAvailable < 1 );
     212    return announcer->slotsAvailable < 1;
    218213}
    219214
     
    249244    a->stops = TR_PTR_ARRAY_INIT;
    250245    a->session = session;
    251     a->announceSlotsAvailable = MAX_CONCURRENT_ANNOUNCES;
    252     a->scrapeSlotsAvailable = MAX_CONCURRENT_SCRAPES;
     246    a->slotsAvailable = MAX_CONCURRENT_TASKS;
    253247    a->upkeepTimer = tr_new0( struct event, 1 );
    254248    evtimer_set( a->upkeepTimer, onUpkeepTimer, a );
     
    13361330    if( announcer != NULL )
    13371331    {
    1338         ++announcer->announceSlotsAvailable;
     1332        ++announcer->slotsAvailable;
    13391333    }
    13401334
     
    13851379    tier->isAnnouncing = TRUE;
    13861380    tier->lastAnnounceStartTime = now;
    1387     --announcer->announceSlotsAvailable;
     1381    --announcer->slotsAvailable;
    13881382    tr_webRun( announcer->session, url, NULL, onAnnounceDone, data );
    13891383
     
    14711465
    14721466    if( announcer )
    1473         ++announcer->scrapeSlotsAvailable;
     1467        ++announcer->slotsAvailable;
    14741468
    14751469    if( announcer && tier )
     
    15631557    tier->isScraping = TRUE;
    15641558    tier->lastScrapeStartTime = now;
    1565     --announcer->scrapeSlotsAvailable;
     1559    --announcer->slotsAvailable;
    15661560    dbgmsg( tier, "scraping \"%s\"", url );
    15671561    tr_webRun( announcer->session, url, NULL, onScrapeDone, data );
     
    15981592tierNeedsToScrape( const tr_tier * tier, const time_t now )
    15991593{
    1600     return tier->isRunning
    1601         && !tier->isScraping
     1594    return ( !tier->isScraping )
    16021595        && ( tier->scrapeAt != 0 )
    16031596        && ( tier->scrapeAt <= now )
     
    16091602announceMore( tr_announcer * announcer )
    16101603{
    1611     const tr_bool canAnnounce = announcer->announceSlotsAvailable > 0;
    1612     const tr_bool canScrape = announcer->scrapeSlotsAvailable > 0;
    16131604    tr_torrent * tor = NULL;
    16141605    const time_t now = tr_time( );
    16151606
    1616     if( announcer->announceSlotsAvailable > 0 )
     1607    if( announcer->slotsAvailable > 0 )
    16171608    {
    16181609        int i;
     
    16271618                for( i=0; i<n; ++i ) {
    16281619                    tr_tier * tier = tr_ptrArrayNth( &tor->tiers->tiers, i );
    1629                     if( canAnnounce && tierNeedsToAnnounce( tier, now ) )
     1620                    if( tierNeedsToAnnounce( tier, now ) )
    16301621                        tr_ptrArrayAppend( &announceMe, tier );
    1631                     else if( canScrape && tierNeedsToScrape( tier, now ) )
     1622                    else if( tierNeedsToScrape( tier, now ) )
    16321623                        tr_ptrArrayAppend( &scrapeMe, tier );
    16331624                }
     
    16371628        /* if there are more tiers than slots available, prioritize */
    16381629        n = tr_ptrArraySize( &announceMe );
    1639         if( n > announcer->announceSlotsAvailable )
     1630        if( n > announcer->slotsAvailable )
    16401631            qsort( tr_ptrArrayBase( &announceMe ), n, sizeof( tr_tier * ), compareTiers );
    16411632
    16421633        /* announce some */
    1643         n = MIN( tr_ptrArraySize( &announceMe ), announcer->announceSlotsAvailable );
     1634        n = MIN( tr_ptrArraySize( &announceMe ), announcer->slotsAvailable );
    16441635        for( i=0; i<n; ++i ) {
    16451636            tr_tier * tier = tr_ptrArrayNth( &announceMe, i );
     
    16481639        }
    16491640
    1650 
    16511641        /* scrape some */
    1652         n = MIN( tr_ptrArraySize( &scrapeMe ), announcer->scrapeSlotsAvailable );
     1642        n = MIN( tr_ptrArraySize( &scrapeMe ), announcer->slotsAvailable );
    16531643        for( i=0; i<n; ++i ) {
    16541644            tr_tier * tier = tr_ptrArrayNth( &scrapeMe, i );
Note: See TracChangeset for help on using the changeset viewer.