From 547056b50b92484568c12375e49f10547b36a3e6 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 3 Jun 2008 04:29:56 +0000 Subject: [PATCH] #988: Optimistic unchoke can unchoke uninterested peers --- libtransmission/peer-mgr.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index cdb80b1d0..57fc4a369 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -1583,21 +1583,30 @@ rechoke( Torrent * t ) /* optimistic unchoke */ if( i < size ) { + int n; struct ChokeData * c; tr_ptrArray * randPool = tr_ptrArrayNew( ); + for( ; idoUnchoke = 1; - t->optimistic = c->peer; + + if(( n = tr_ptrArraySize( randPool ))) + { + c = tr_ptrArrayNth( randPool, tr_rand( n )); + c->doUnchoke = 1; + t->optimistic = c->peer; + } + tr_ptrArrayFree( randPool, NULL ); } -- 2.40.0