Changeset 11790


Ignore:
Timestamp:
Jan 30, 2011, 4:23:53 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) #3931 "announce is queued" -- minor revision for uClibc compatibility

jusid reports that powl() doesn't exist on uClibc, so getRetryInterval() needs to work without it. A simple left-bit shifting would be fine, but since we max out after a handful of cases, a switch statement seems slightly more readable than shifting or powl().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r11784 r11790  
    1313#include <assert.h>
    1414#include <limits.h>
    15 #include <math.h> /* powl() */
    1615
    1716#include <event2/buffer.h>
     
    10901089getRetryInterval( const tr_tracker_item * t )
    10911090{
    1092     const int jitter_seconds = tr_cryptoWeakRandInt( 60 );
    1093     const int minutes = powl( t->consecutiveAnnounceFailures, 2 );
    1094     return ( MIN( minutes, 128 ) * 60 ) + jitter_seconds;
     1091    int minutes;
     1092    const unsigned int jitter_seconds = tr_cryptoWeakRandInt( 60 );
     1093    switch( t->consecutiveAnnounceFailures ) {
     1094        case 0:  minutes =   1; break;
     1095        case 1:  minutes =   2; break;
     1096        case 2:  minutes =   4; break;
     1097        case 3:  minutes =   8; break;
     1098        case 4:  minutes =  16; break;
     1099        case 5:  minutes =  32; break;
     1100        case 6:  minutes =  64; break;
     1101        default: minutes = 128; break;
     1102    }
     1103    return ( minutes * 60 ) + jitter_seconds;
    10951104}
    10961105
Note: See TracChangeset for help on using the changeset viewer.