1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00

more of the same

This commit is contained in:
Charles Kerr 2007-11-15 05:47:23 +00:00
parent ea3a1387f2
commit 257eaee631
2 changed files with 11 additions and 14 deletions

View file

@ -1438,8 +1438,7 @@ tr_peerMgrPeerStats( const tr_peerMgr * manager,
struct ChokeData
{
tr_peer * peer;
float rate;
int randomKey;
double rate;
int preferred;
int doUnchoke;
};
@ -1447,22 +1446,17 @@ struct ChokeData
static int
compareChoke( const void * va, const void * vb )
{
int i;
const struct ChokeData * a = va;
const struct ChokeData * b = vb;
if(( i = (int)( 10 * ( a->rate - b->rate ))))
return i;
if( a->preferred != b->preferred )
return a->preferred ? -1 : 1;
if( a->preferred )
{
if( a->rate > b->rate ) return -1;
if( a->rate < b->rate ) return 1;
return 0;
}
else
{
return a->randomKey - b->randomKey;
}
return 0;
}
static int
@ -1480,7 +1474,7 @@ clientIsSnubbedBy( const tr_peer * peer )
static double
getWeightedThroughput( const tr_peer * peer )
{
/* FIXME: tweak this */
/* FIXME: tweak this? */
return ( 1 * peer->rateToPeer )
+ ( 1 * peer->rateToClient );
}
@ -1506,7 +1500,6 @@ rechoke( Torrent * t )
node = &choke[size++];
node->peer = peer;
node->preferred = peer->peerIsInterested && !clientIsSnubbedBy(peer);
node->randomKey = tr_rand( INT_MAX );
node->rate = getWeightedThroughput( peer );
}

View file

@ -569,6 +569,9 @@ pumpRequestQueue( tr_peermsgs * msgs )
fireNeedReq( msgs );
}
static int
pulse( void * vmsgs );
int
tr_peerMsgsAddRequest( tr_peermsgs * msgs,
uint32_t index,
@ -623,6 +626,7 @@ tr_peerMsgsAddRequest( tr_peermsgs * msgs,
req = tr_new0( struct peer_request, 1 );
*req = tmp;
tr_list_append( &msgs->clientWillAskFor, req );
pulse( msgs );
return TR_ADDREQ_OK;
}