Changeset 7119


Ignore:
Timestamp:
Nov 16, 2008, 8:56:18 AM (12 years ago)
Author:
charles
Message:

(libT) #1474: lazy bitfields don't work quite right in 1.40

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-msgs.c

    r7065 r7119  
    18481848            speed over a truly random sample -- let's limit the pool size to
    18491849            the first 1000 pieces so large torrents don't bog things down */
    1850         size_t             poolSize = MIN( msgs->torrent->info.pieceCount,
    1851                                           1000 );
    1852         tr_piece_index_t * pool = tr_new( tr_piece_index_t, poolSize );
     1850        size_t poolSize;
     1851        const size_t maxPoolSize = MIN( msgs->torrent->info.pieceCount, 1000 );
     1852        tr_piece_index_t * pool = tr_new( tr_piece_index_t, maxPoolSize );
    18531853
    18541854        /* build the pool */
    1855         for( i = 0; i < poolSize; ++i )
    1856             pool[i] = i;
     1855        for( i=poolSize=0; i<maxPoolSize; ++i )
     1856            if( tr_bitfieldHas( field, i ) )
     1857                pool[poolSize++] = i;
    18571858
    18581859        /* pull random piece indices from the pool */
    18591860        while( ( poolSize > 0 ) && ( lazyCount < LAZY_PIECE_COUNT ) )
    18601861        {
    1861             const int              pos = tr_cryptoWeakRandInt( poolSize );
     1862            const int pos = tr_cryptoWeakRandInt( poolSize );
    18621863            const tr_piece_index_t piece = pool[pos];
    18631864            tr_bitfieldRem( field, piece );
Note: See TracChangeset for help on using the changeset viewer.