mirror of
https://github.com/transmission/transmission
synced 2024-12-27 01:57:52 +00:00
more of the same
This commit is contained in:
parent
ea3a1387f2
commit
257eaee631
2 changed files with 11 additions and 14 deletions
|
@ -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,23 +1446,18 @@ 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
|
||||||
clientIsSnubbedBy( const tr_peer * peer )
|
clientIsSnubbedBy( const tr_peer * peer )
|
||||||
|
@ -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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue