mirror of
https://github.com/transmission/transmission
synced 2024-12-23 16:24:02 +00:00
(libT) fix r7109 oops spotted by BentMyWookie
This commit is contained in:
parent
930b94a4de
commit
d42fae7dce
1 changed files with 10 additions and 9 deletions
|
@ -1842,7 +1842,8 @@ struct ChokeData
|
|||
{
|
||||
unsigned int doUnchoke : 1;
|
||||
unsigned int isInterested : 1;
|
||||
double rate;
|
||||
unsigned int isChoked : 1;
|
||||
int rate;
|
||||
tr_peer * peer;
|
||||
};
|
||||
|
||||
|
@ -1852,15 +1853,14 @@ compareChoke( const void * va,
|
|||
{
|
||||
const struct ChokeData * a = va;
|
||||
const struct ChokeData * b = vb;
|
||||
int diff = 0;
|
||||
|
||||
if( diff == 0 ) /* prefer higher overall speeds */
|
||||
diff = a->rate > b->rate ? -1 : 1;
|
||||
if( a->rate != b->rate ) /* prefer higher overall speeds */
|
||||
return a->rate > b->rate ? -1 : 1;
|
||||
|
||||
if( diff == 0 ) /* prefer unchoked */
|
||||
diff = (int)a->peer->peerIsChoked - (int)b->peer->peerIsChoked;
|
||||
if( a->isChoked != b->isChoked ) /* prefer unchoked */
|
||||
return a->isChoked ? 1 : -1;
|
||||
|
||||
return diff;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1901,8 +1901,9 @@ rechoke( Torrent * t )
|
|||
struct ChokeData * n = &choke[size++];
|
||||
n->peer = peer;
|
||||
n->isInterested = peer->peerIsInterested;
|
||||
n->rate = tr_peerGetPieceSpeed( peer, TR_CLIENT_TO_PEER )
|
||||
+ tr_peerGetPieceSpeed( peer, TR_PEER_TO_CLIENT );
|
||||
n->isChoked = peer->peerIsChoked;
|
||||
n->rate = (int)(tr_peerGetPieceSpeed( peer, TR_CLIENT_TO_PEER )
|
||||
+ tr_peerGetPieceSpeed( peer, TR_PEER_TO_CLIENT ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue