mirror of
https://github.com/transmission/transmission
synced 2024-12-23 00:04:06 +00:00
(trunk libT) #3596 "optimistic unchoke timer is too short" -- fixed.
This commit is contained in:
parent
4b70747592
commit
1f9e305e30
1 changed files with 17 additions and 3 deletions
|
@ -48,6 +48,10 @@ enum
|
||||||
/* how frequently to change which peers are choked */
|
/* how frequently to change which peers are choked */
|
||||||
RECHOKE_PERIOD_MSEC = ( 10 * 1000 ),
|
RECHOKE_PERIOD_MSEC = ( 10 * 1000 ),
|
||||||
|
|
||||||
|
/* an optimistically unchoked peer is immune from rechoking
|
||||||
|
for this many calls to rechokeUploads(). */
|
||||||
|
OPTIMISTIC_UNCHOKE_MULTIPLIER = 4,
|
||||||
|
|
||||||
/* how frequently to reallocate bandwidth */
|
/* how frequently to reallocate bandwidth */
|
||||||
BANDWIDTH_PERIOD_MSEC = 500,
|
BANDWIDTH_PERIOD_MSEC = 500,
|
||||||
|
|
||||||
|
@ -179,9 +183,11 @@ typedef struct tr_torrent_peers
|
||||||
tr_ptrArray webseeds; /* tr_webseed */
|
tr_ptrArray webseeds; /* tr_webseed */
|
||||||
|
|
||||||
tr_torrent * tor;
|
tr_torrent * tor;
|
||||||
tr_peer * optimistic; /* the optimistic peer, or NULL if none */
|
|
||||||
struct tr_peerMgr * manager;
|
struct tr_peerMgr * manager;
|
||||||
|
|
||||||
|
tr_peer * optimistic; /* the optimistic peer, or NULL if none */
|
||||||
|
int optimisticUnchokeTimeScaler;
|
||||||
|
|
||||||
tr_bool isRunning;
|
tr_bool isRunning;
|
||||||
tr_bool needsCompletenessCheck;
|
tr_bool needsCompletenessCheck;
|
||||||
|
|
||||||
|
@ -2709,6 +2715,13 @@ rechokeUploads( Torrent * t, const uint64_t now )
|
||||||
|
|
||||||
assert( torrentIsLocked( t ) );
|
assert( torrentIsLocked( t ) );
|
||||||
|
|
||||||
|
/* an optimistic unchoke peer's "optimistic"
|
||||||
|
* state lasts for N calls to rechokeUploads(). */
|
||||||
|
if( t->optimisticUnchokeTimeScaler > 0 )
|
||||||
|
t->optimisticUnchokeTimeScaler--;
|
||||||
|
else
|
||||||
|
t->optimistic = NULL;
|
||||||
|
|
||||||
/* sort the peers by preference and rate */
|
/* sort the peers by preference and rate */
|
||||||
for( i = 0, size = 0; i < peerCount; ++i )
|
for( i = 0, size = 0; i < peerCount; ++i )
|
||||||
{
|
{
|
||||||
|
@ -2727,7 +2740,7 @@ rechokeUploads( Torrent * t, const uint64_t now )
|
||||||
{
|
{
|
||||||
tr_peerMsgsSetChoke( peer->msgs, TRUE );
|
tr_peerMsgsSetChoke( peer->msgs, TRUE );
|
||||||
}
|
}
|
||||||
else
|
else if( peer != t->optimistic )
|
||||||
{
|
{
|
||||||
struct ChokeData * n = &choke[size++];
|
struct ChokeData * n = &choke[size++];
|
||||||
n->peer = peer;
|
n->peer = peer;
|
||||||
|
@ -2764,7 +2777,7 @@ rechokeUploads( Torrent * t, const uint64_t now )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* optimistic unchoke */
|
/* optimistic unchoke */
|
||||||
if( !isMaxedOut && (i<size) )
|
if( !t->optimistic && !isMaxedOut && (i<size) )
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
struct ChokeData * c;
|
struct ChokeData * c;
|
||||||
|
@ -2787,6 +2800,7 @@ rechokeUploads( Torrent * t, const uint64_t now )
|
||||||
c = tr_ptrArrayNth( &randPool, tr_cryptoWeakRandInt( n ));
|
c = tr_ptrArrayNth( &randPool, tr_cryptoWeakRandInt( n ));
|
||||||
c->isChoked = FALSE;
|
c->isChoked = FALSE;
|
||||||
t->optimistic = c->peer;
|
t->optimistic = c->peer;
|
||||||
|
t->optimisticUnchokeTimeScaler = OPTIMISTIC_UNCHOKE_MULTIPLIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr_ptrArrayDestruct( &randPool, NULL );
|
tr_ptrArrayDestruct( &randPool, NULL );
|
||||||
|
|
Loading…
Reference in a new issue