(libT) some people have complained that Transmission doesn't upload enough until after downloading is complete. This commit ought to fix that.

This commit is contained in:
Charles Kerr 2008-11-15 00:46:51 +00:00
parent 763ce2d9a3
commit 930b94a4de
1 changed files with 6 additions and 17 deletions

View File

@ -1842,20 +1842,10 @@ struct ChokeData
{
unsigned int doUnchoke : 1;
unsigned int isInterested : 1;
double rateToClient;
double rateToPeer;
double rate;
tr_peer * peer;
};
static int
tr_compareDouble( double a,
double b )
{
if( a < b ) return -1;
if( a > b ) return 1;
return 0;
}
static int
compareChoke( const void * va,
const void * vb )
@ -1864,10 +1854,9 @@ compareChoke( const void * va,
const struct ChokeData * b = vb;
int diff = 0;
if( diff == 0 ) /* prefer higher dl speeds */
diff = -tr_compareDouble( a->rateToClient, b->rateToClient );
if( diff == 0 ) /* prefer higher ul speeds */
diff = -tr_compareDouble( a->rateToPeer, b->rateToPeer );
if( diff == 0 ) /* prefer higher overall speeds */
diff = a->rate > b->rate ? -1 : 1;
if( diff == 0 ) /* prefer unchoked */
diff = (int)a->peer->peerIsChoked - (int)b->peer->peerIsChoked;
@ -1912,8 +1901,8 @@ rechoke( Torrent * t )
struct ChokeData * n = &choke[size++];
n->peer = peer;
n->isInterested = peer->peerIsInterested;
n->rateToPeer = tr_peerGetPieceSpeed( peer, TR_CLIENT_TO_PEER );
n->rateToClient = tr_peerGetPieceSpeed( peer, TR_PEER_TO_CLIENT );
n->rate = tr_peerGetPieceSpeed( peer, TR_CLIENT_TO_PEER )
+ tr_peerGetPieceSpeed( peer, TR_PEER_TO_CLIENT );
}
}