mirror of
https://github.com/transmission/transmission
synced 2024-12-27 18:18:10 +00:00
some more peer tweaks
This commit is contained in:
parent
a3d1a254d1
commit
877e2bb86e
2 changed files with 6 additions and 20 deletions
|
@ -1432,20 +1432,14 @@ rechokePulse( void * vtorrent )
|
||||||
****
|
****
|
||||||
***/
|
***/
|
||||||
|
|
||||||
struct tr_connection
|
|
||||||
{
|
|
||||||
tr_peer * peer;
|
|
||||||
double throughput;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define LAISSEZ_FAIRE_PERIOD_SECS 90
|
#define LAISSEZ_FAIRE_PERIOD_SECS 90
|
||||||
|
|
||||||
static struct tr_connection *
|
static tr_peer **
|
||||||
getWeakConnections( Torrent * t, int * setmeSize )
|
getWeakConnections( Torrent * t, int * setmeSize )
|
||||||
{
|
{
|
||||||
int i, insize, outsize;
|
int i, insize, outsize;
|
||||||
tr_peer ** peers = (tr_peer**) tr_ptrArrayPeek( t->peers, &insize );
|
tr_peer ** peers = (tr_peer**) tr_ptrArrayPeek( t->peers, &insize );
|
||||||
struct tr_connection * ret = tr_new( struct tr_connection, insize );
|
struct tr_peer ** ret = tr_new( tr_peer*, insize );
|
||||||
const int clientIsSeed = tr_cpGetStatus( t->tor->completion ) != TR_CP_INCOMPLETE;
|
const int clientIsSeed = tr_cpGetStatus( t->tor->completion ) != TR_CP_INCOMPLETE;
|
||||||
const time_t now = time( NULL );
|
const time_t now = time( NULL );
|
||||||
|
|
||||||
|
@ -1474,11 +1468,7 @@ getWeakConnections( Torrent * t, int * setmeSize )
|
||||||
isWeak = ( now - peer->pieceDataActivityDate ) > 180;
|
isWeak = ( now - peer->pieceDataActivityDate ) > 180;
|
||||||
|
|
||||||
if( isWeak )
|
if( isWeak )
|
||||||
{
|
ret[outsize++] = peer;
|
||||||
ret[outsize].peer = peer;
|
|
||||||
ret[outsize].throughput = throughput;
|
|
||||||
++outsize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*setmeSize = outsize;
|
*setmeSize = outsize;
|
||||||
|
@ -1556,19 +1546,15 @@ reconnectPulse( void * vtorrent )
|
||||||
{
|
{
|
||||||
int i, nCandidates, nWeak, nAdd;
|
int i, nCandidates, nWeak, nAdd;
|
||||||
struct peer_atom ** candidates = getPeerCandidates( t, &nCandidates );
|
struct peer_atom ** candidates = getPeerCandidates( t, &nCandidates );
|
||||||
struct tr_connection * connections = getWeakConnections( t, &nWeak );
|
struct tr_peer ** connections = getWeakConnections( t, &nWeak );
|
||||||
const int peerCount = tr_ptrArraySize( t->peers );
|
const int peerCount = tr_ptrArraySize( t->peers );
|
||||||
|
|
||||||
tordbg( t, "RECONNECT pulse for [%s]: %d weak connections, %d connection candidates, %d atoms, max per pulse is %d",
|
tordbg( t, "RECONNECT pulse for [%s]: %d weak connections, %d connection candidates, %d atoms, max per pulse is %d",
|
||||||
t->tor->info.name, nWeak, nCandidates, tr_ptrArraySize(t->pool), (int)MAX_RECONNECTIONS_PER_PULSE );
|
t->tor->info.name, nWeak, nCandidates, tr_ptrArraySize(t->pool), (int)MAX_RECONNECTIONS_PER_PULSE );
|
||||||
|
|
||||||
for( i=0; i<nWeak; ++i )
|
|
||||||
tordbg( t, "connection #%d: %s @ %.2f", i+1,
|
|
||||||
tr_peerIoAddrStr( &connections[i].peer->in_addr, connections[i].peer->port ), connections[i].throughput );
|
|
||||||
|
|
||||||
/* disconnect some peers */
|
/* disconnect some peers */
|
||||||
for( i=0; i<nWeak; ++i )
|
for( i=0; i<nWeak; ++i )
|
||||||
removePeer( t, connections[i].peer );
|
removePeer( t, connections[i] );
|
||||||
|
|
||||||
/* add some new ones */
|
/* add some new ones */
|
||||||
nAdd = MAX_CONNECTED_PEERS_PER_TORRENT - peerCount;
|
nAdd = MAX_CONNECTED_PEERS_PER_TORRENT - peerCount;
|
||||||
|
|
|
@ -68,7 +68,7 @@ enum
|
||||||
|
|
||||||
KEEPALIVE_INTERVAL_SECS = 90, /* idle seconds before we send a keepalive */
|
KEEPALIVE_INTERVAL_SECS = 90, /* idle seconds before we send a keepalive */
|
||||||
PEX_INTERVAL = (60 * 1000), /* msec between calls to sendPex() */
|
PEX_INTERVAL = (60 * 1000), /* msec between calls to sendPex() */
|
||||||
PEER_PULSE_INTERVAL = (50) , /* msec between calls to pulse() */
|
PEER_PULSE_INTERVAL = (33), /* msec between calls to pulse() */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
|
Loading…
Reference in a new issue