From f9c6deab6fd3ddcaf119b289182eb3887debde75 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Thu, 3 Mar 2011 07:20:18 +0000 Subject: [PATCH] (trunk libT) minor revision to r12065: clamp the bandwidth before applying the ratio calculation --- libtransmission/bandwidth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libtransmission/bandwidth.c b/libtransmission/bandwidth.c index 97f921f16..500d34bf6 100644 --- a/libtransmission/bandwidth.c +++ b/libtransmission/bandwidth.c @@ -323,13 +323,14 @@ bandwidthClamp( const tr_bandwidth * b, double desired = tr_bandwidthGetDesiredSpeed_Bps( b, TR_DOWN ); double r = desired > 0.001 ? current / desired : 0; size_t i; + + byteCount = MIN( byteCount, b->band[dir].bytesLeft ); + if( r > 1.0 ) i = 0; else if( r > 0.9 ) i = byteCount * 0.9; else if( r > 0.8 ) i = byteCount * 0.8; else i = byteCount; - byteCount = MIN( byteCount, b->band[dir].bytesLeft ); - //fprintf( stderr, "--> %.4f (%f... %f) [%zu --> %zu]\n", r, current, desired, byteCount, i ); byteCount = i; }