Changeset 12905


Ignore:
Timestamp:
Sep 21, 2011, 11:04:39 PM (10 years ago)
Author:
jordan
Message:

#4496 'freeze when having a huge torrent' -- more tweaks based on Shark reports from MechMK1

File:
1 edited

Legend:

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

    r12653 r12905  
    27762776static bool
    27772777isPeerInteresting( const tr_torrent  * const tor,
    2778                    const tr_bitfield * const interesting_pieces,
     2778                   const bool        * const piece_is_interesting,
    27792779                   const tr_peer     * const peer )
    27802780{
     
    27892789
    27902790    for( i=0, n=tor->info.pieceCount; i<n; ++i )
    2791         if( tr_bitfieldHas( interesting_pieces, i ) && tr_bitfieldHas( &peer->have, i ) )
     2791        if( piece_is_interesting[i] && tr_bitfieldHas( &peer->have, i ) )
    27922792            return true;
    27932793
     
    29102910    if( peerCount > 0 )
    29112911    {
     2912        bool * piece_is_interesting;
    29122913        const tr_torrent * const tor = t->tor;
    29132914        const int n = tor->info.pieceCount;
    2914         tr_bitfield interesting_pieces = TR_BITFIELD_INIT;
    29152915
    29162916        /* build a bitfield of interesting pieces... */
    2917         tr_bitfieldConstruct( &interesting_pieces, n );
     2917        piece_is_interesting = tr_new( bool, n );
    29182918        for( i=0; i<n; i++ )
    2919             if( !tor->info.pieces[i].dnd && !tr_cpPieceIsComplete( &tor->completion, i ) )
    2920                 tr_bitfieldAdd( &interesting_pieces, i );
     2919            piece_is_interesting[i] = !tor->info.pieces[i].dnd && !tr_cpPieceIsComplete( &tor->completion, i );
    29212920
    29222921        /* decide WHICH peers to be interested in (based on their cancel-to-block ratio) */
     
    29252924            tr_peer * peer = tr_ptrArrayNth( &t->peers, i );
    29262925
    2927             if( !isPeerInteresting( t->tor, &interesting_pieces, peer ) )
     2926            if( !isPeerInteresting( t->tor, piece_is_interesting, peer ) )
    29282927            {
    29292928                tr_peerMsgsSetInterested( peer->msgs, false );
     
    29572956        }
    29582957
    2959         tr_bitfieldDestruct( &interesting_pieces );
     2958        tr_free( piece_is_interesting );
    29602959    }
    29612960
Note: See TracChangeset for help on using the changeset viewer.