mirror of
https://github.com/transmission/transmission
synced 2024-12-27 01:57:52 +00:00
#988: Optimistic unchoke can unchoke uninterested peers
This commit is contained in:
parent
44fdf34678
commit
547056b50b
1 changed files with 19 additions and 10 deletions
|
@ -1583,9 +1583,13 @@ rechoke( Torrent * t )
|
|||
/* optimistic unchoke */
|
||||
if( i < size )
|
||||
{
|
||||
int n;
|
||||
struct ChokeData * c;
|
||||
tr_ptrArray * randPool = tr_ptrArrayNew( );
|
||||
|
||||
for( ; i<size; ++i )
|
||||
{
|
||||
if( choke[i].isInterested )
|
||||
{
|
||||
const tr_peer * peer = choke[i].peer;
|
||||
int x=1, y;
|
||||
|
@ -1594,10 +1598,15 @@ rechoke( Torrent * t )
|
|||
for( y=0; y<x; ++y )
|
||||
tr_ptrArrayAppend( randPool, choke );
|
||||
}
|
||||
i = tr_rand( tr_ptrArraySize( randPool ) );
|
||||
c = tr_ptrArrayNth( randPool, i);
|
||||
}
|
||||
|
||||
if(( n = tr_ptrArraySize( randPool )))
|
||||
{
|
||||
c = tr_ptrArrayNth( randPool, tr_rand( n ));
|
||||
c->doUnchoke = 1;
|
||||
t->optimistic = c->peer;
|
||||
}
|
||||
|
||||
tr_ptrArrayFree( randPool, NULL );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue