return a;
}
-/* set 'a' to all the flags that were in 'a' but not 'b' */
-void
-tr_bitfieldDifference( tr_bitfield * a, const tr_bitfield * b )
-{
- uint8_t * ait = a->bits;
- const uint8_t * aend = ait + a->byteCount;
- const uint8_t * bit = b->bits;
- const uint8_t * bend = bit + b->byteCount;
-
- while( ait!=aend && bit!=bend )
- *ait++ &= ~( *bit++ );
-}
-
size_t
tr_bitfieldCountTrueBits( const tr_bitfield* b )
{
int tr_bitfieldRemRange( tr_bitfield*, size_t begin, size_t end );
-void tr_bitfieldDifference( tr_bitfield *, const tr_bitfield * );
-
int tr_bitfieldIsEmpty( const tr_bitfield* );
size_t tr_bitfieldCountTrueBits( const tr_bitfield* );
tr_bitfieldOr( a, &b->bitfield );
}
-/* set 'a' to all the flags that were in 'a' but not 'b' */
-void
-tr_bitsetDifference( tr_bitfield * a, const tr_bitset * b )
-{
- if( b->haveAll )
- tr_bitfieldClear( a );
- else if( !b->haveNone )
- tr_bitfieldDifference( a, &b->bitfield );
-}
-
double
tr_bitsetPercent( const tr_bitset * b )
{
void tr_bitsetOr( tr_bitfield * a, const tr_bitset * b );
-/* set 'a' to all the flags that were in 'a' but not 'b' */
-void tr_bitsetDifference( tr_bitfield * a, const tr_bitset * b );
-
#endif
/* if we're seeding and the peer has everything we have,
* and enough time has passed for a pex exchange, then disconnect */
- if( tr_torrentIsSeed( tor ) )
- {
- tr_bool peerHasEverything;
-
- if( atom->seedProbability != -1 )
- {
- peerHasEverything = atomIsSeed( atom );
- }
- else
- {
- tr_bitfield * tmp = tr_bitfieldDup( tr_cpPieceBitfield( &tor->completion ) );
- tr_bitsetDifference( tmp, &peer->have );
- peerHasEverything = tr_bitfieldCountTrueBits( tmp ) == 0;
- tr_bitfieldFree( tmp );
- }
-
- if( peerHasEverything && ( !tr_torrentAllowsPex(tor) || (now-atom->time>=30 )))
- {
- tordbg( t, "purging peer %s because we're both seeds",
- tr_atomAddrStr( atom ) );
- return TRUE;
- }
- }
+ if( tr_torrentIsSeed( tor ) && ( peer->progress >= 1.0f ) )
+ return !tr_torrentAllowsPex(tor) || (now-atom->time>=30);
/* disconnect if it's been too long since piece data has been transferred.
* this is on a sliding scale based on number of available peers... */