1
0
Fork 0
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:
Charles Kerr 2008-06-03 04:29:56 +00:00
parent 44fdf34678
commit 547056b50b

View file

@ -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 );
}