Changeset 11730


Ignore:
Timestamp:
Jan 20, 2011, 10:51:05 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) #3870 "transmission doesn't recheck after getting initial 404" -- fixed.

The exponentially-growing interval between retries had a bug that caused intervals to be too long if no successful announce had ever been made. This commit fixes the code that calculates the interval.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r11729 r11730  
    308308    int downloadCount;
    309309    int downloaderCount;
     310
     311    int consecutiveAnnounceFailures;
    310312
    311313    uint32_t id;
     
    10951097
    10961098static int
    1097 getRetryInterval( const tr_host * host )
    1098 {
    1099     int interval;
    1100     const int jitter = tr_cryptoWeakRandInt( 120 );
    1101     const time_t timeSinceLastSuccess = tr_time() - host->lastSuccessfulRequest;
    1102          if( timeSinceLastSuccess < 15*60 ) interval = 0;
    1103     else if( timeSinceLastSuccess < 30*60 ) interval = 60*4;
    1104     else if( timeSinceLastSuccess < 45*60 ) interval = 60*8;
    1105     else if( timeSinceLastSuccess < 60*60 ) interval = 60*16;
    1106     else                                    interval = 60*32;
    1107     return interval + jitter;
     1099getRetryInterval( const tr_tracker_item * t )
     1100{
     1101    int minutes;
     1102    const int jitter_seconds = tr_cryptoWeakRandInt( 120 );
     1103
     1104    switch( t->consecutiveAnnounceFailures ) {
     1105        case 0:  minutes =  0; break;
     1106        case 1:  minutes =  1; break;
     1107        case 2:  minutes =  2; break;
     1108        case 3:  minutes =  4; break;
     1109        case 4:  minutes =  8; break;
     1110        case 5:  minutes = 16; break;
     1111        default: minutes = 32; break;
     1112    }
     1113
     1114    return ( minutes * 60 ) + jitter_seconds;
    11081115}
    11091116
     
    13661373        if( responseCode == HTTP_OK )
    13671374        {
     1375            tier->currentTracker->consecutiveAnnounceFailures = 0;
    13681376            success = parseAnnounceResponse( tier, response, responseLen, &gotScrape );
    13691377            dbgmsg( tier, "success is %d", success );
     
    13911399                        sizeof( tier->lastAnnounceStr ) );
    13921400
     1401            ++tier->currentTracker->consecutiveAnnounceFailures;
     1402
    13931403            /* if the response is serious, *and* if the response may require
    13941404             * human intervention, then notify the user... otherwise just log it */
     
    14161426        if( responseCode == 0 )
    14171427        {
    1418             const int interval = getRetryInterval( tier->currentTracker->host );
     1428            const int interval = getRetryInterval( tier->currentTracker );
    14191429            dbgmsg( tier, "No response from tracker... retrying in %d seconds.", interval );
    14201430            tier->manualAnnounceAllowedAt = ~(time_t)0;
     
    14591469             * So we pause a bit and try again. */
    14601470
    1461             const int interval = getRetryInterval( tier->currentTracker->host );
     1471            const int interval = getRetryInterval( tier->currentTracker );
    14621472            tier->manualAnnounceAllowedAt = ~(time_t)0;
    14631473            tierAddAnnounce( tier, announceEvent, now + interval );
     
    17251735        else
    17261736        {
    1727             const int interval = getRetryInterval( tier->currentTracker->host );
     1737            const int interval = getRetryInterval( tier->currentTracker );
    17281738
    17291739            /* Don't retry on a 4xx.
Note: See TracChangeset for help on using the changeset viewer.