Changeset 7222


Ignore:
Timestamp:
Dec 1, 2008, 4:47:59 PM (12 years ago)
Author:
charles
Message:

(libT) possible fix for #1545: "1.41b1: speed temporarily jumps to 2x the upload limit"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.4x/libtransmission/bandwidth.c

    r7177 r7222  
    258258        const double desiredSpeed = b->band[dir].desiredSpeed;
    259259        const double pulseCount = ( HISTORY_MSEC - period_msec ) / (double)period_msec;
    260         const double nextPulseSpeed = desiredSpeed * ( pulseCount + 1 ) - ( currentSpeed * pulseCount );
    261         b->band[dir].bytesLeft = MAX( 0.0, nextPulseSpeed * 1024.0 * period_msec / 1000.0 );
     260        double nextPulseSpeed = desiredSpeed * ( pulseCount + 1 ) - ( currentSpeed * pulseCount );
     261
     262        /* clamp the speed to prevent oscillation */
     263        const double minSpeed = desiredSpeed * 0.8;
     264        const double maxSpeed = desiredSpeed * 1.2;
     265        nextPulseSpeed = MAX( minSpeed, nextPulseSpeed );
     266        nextPulseSpeed = MIN( maxSpeed, nextPulseSpeed );
     267
     268        b->band[dir].bytesLeft = nextPulseSpeed * 1024.0 * period_msec / 1000.0;
    262269
    263270#ifdef DEBUG_DIRECTION
Note: See TracChangeset for help on using the changeset viewer.