1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 17:47:37 +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 struct ChokeData
{ {
tr_peer * peer; tr_peer * peer;
float rate; double rate;
int randomKey;
int preferred; int preferred;
int doUnchoke; int doUnchoke;
}; };
@ -1447,22 +1446,17 @@ struct ChokeData
static int static int
compareChoke( const void * va, const void * vb ) compareChoke( const void * va, const void * vb )
{ {
int i;
const struct ChokeData * a = va; const struct ChokeData * a = va;
const struct ChokeData * b = vb; const struct ChokeData * b = vb;
if(( i = (int)( 10 * ( a->rate - b->rate ))))
return i;
if( a->preferred != b->preferred ) if( a->preferred != b->preferred )
return a->preferred ? -1 : 1; return a->preferred ? -1 : 1;
if( a->preferred )
{
if( a->rate > b->rate ) return -1;
if( a->rate < b->rate ) return 1;
return 0; return 0;
}
else
{
return a->randomKey - b->randomKey;
}
} }
static int static int
@ -1480,7 +1474,7 @@ clientIsSnubbedBy( const tr_peer * peer )
static double static double
getWeightedThroughput( const tr_peer * peer ) getWeightedThroughput( const tr_peer * peer )
{ {
/* FIXME: tweak this */ /* FIXME: tweak this? */
return ( 1 * peer->rateToPeer ) return ( 1 * peer->rateToPeer )
+ ( 1 * peer->rateToClient ); + ( 1 * peer->rateToClient );
} }
@ -1506,7 +1500,6 @@ rechoke( Torrent * t )
node = &choke[size++]; node = &choke[size++];
node->peer = peer; node->peer = peer;
node->preferred = peer->peerIsInterested && !clientIsSnubbedBy(peer); node->preferred = peer->peerIsInterested && !clientIsSnubbedBy(peer);
node->randomKey = tr_rand( INT_MAX );
node->rate = getWeightedThroughput( peer ); node->rate = getWeightedThroughput( peer );
} }

View file

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