Changeset 13032


Ignore:
Timestamp:
Oct 25, 2011, 4:56:19 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) #4592 "Algorithm bug in bandwidth allocation" -- apply patch from Algorithmus

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bandwidth.c

    r12653 r13032  
    208208    n = peerCount;
    209209    dbgmsg( "%d peers to go round-robin for %s", n, (dir==TR_UP?"upload":"download") );
    210     i = n ? tr_cryptoWeakRandInt( n ) : 0; /* pick a random starting point */
    211210    while( n > 0 )
    212211    {
     212        i = n ? tr_cryptoWeakRandInt( n ) : 0; /* pick a peer at random */
     213
    213214        /* value of 3000 bytes chosen so that when using uTP we'll send a full-size
    214215         * frame right away and leave enough buffered data for the next frame to go
     
    220221        dbgmsg( "peer #%d of %d used %d bytes in this pass", i, n, bytesUsed );
    221222
    222         if( bytesUsed == (int)increment )
    223             ++i;
    224         else {
     223        if( bytesUsed != (int)increment ) {
    225224            /* peer is done writing for now; move it to the end of the list */
    226225            tr_peerIo * pio = peers[i];
     
    229228            --n;
    230229        }
    231 
    232         if( i >= n )
    233             i = 0;
    234230    }
    235231}
Note: See TracChangeset for help on using the changeset viewer.