Changeset 12019


Ignore:
Timestamp:
Feb 24, 2011, 1:50:35 AM (11 years ago)
Author:
jordan
Message:

(trunk libT) if we're a partial seed and the peer has everything we have, disconnect.

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bitset.c

    r12012 r12019  
    160160}
    161161
     162/* return true if "b" is equal to, or a superset of, "set" */
     163tr_bool
     164tr_bitsetHasSet( const tr_bitset * b, const tr_bitset * set )
     165{
     166    const uint8_t * bit = b->bitfield.bits;
     167    const uint8_t * bend = bit + b->bitfield.byteCount;
     168    const uint8_t * sit = set->bitfield.bits;
     169    const uint8_t * send = sit + set->bitfield.byteCount;
     170   
     171    if( b->haveAll || set->haveAll )
     172        return b->haveAll;
     173
     174    if( b->haveNone || set->haveNone )
     175        return set->haveNone;
     176
     177    for( ; bit!=bend && sit!=send; ++bit, ++sit )
     178        if( ( *bit & *sit ) != *sit )
     179            return FALSE;
     180
     181    return TRUE;
     182}
     183
    162184double
    163185tr_bitsetPercent( const tr_bitset * b )
  • trunk/libtransmission/bitset.h

    r12012 r12019  
    5555
    5656tr_bool tr_bitsetHas( const tr_bitset * b, const size_t nth );
     57tr_bool tr_bitsetHasSet( const tr_bitset * b, const tr_bitset * compare );
    5758size_t tr_bitsetCountRange( const tr_bitset * b, const size_t begin, const size_t end );
    5859
  • trunk/libtransmission/peer-mgr.c

    r12015 r12019  
    31103110    /* if we're seeding and the peer has everything we have,
    31113111     * and enough time has passed for a pex exchange, then disconnect */
    3112     if( tr_torrentIsSeed( tor ) && ( peer->progress >= 1.0f ) )
     3112    if( tr_torrentIsSeed( tor ) && tr_bitsetHasSet( &peer->have, tr_cpBlockBitset( &tor->completion ) ) )
    31133113        return !tr_torrentAllowsPex(tor) || (now-atom->time>=30);
    31143114
Note: See TracChangeset for help on using the changeset viewer.