mirror of
https://github.com/transmission/transmission
synced 2024-12-26 01:27:28 +00:00
(trunk libT) when pruning out slow peers, don't prune if we don't have good candidates to replace them.
This commit is contained in:
parent
1375c707ed
commit
69404a8c36
1 changed files with 10 additions and 4 deletions
|
@ -2212,6 +2212,12 @@ reconnectPulse( void * vtorrent )
|
|||
int i, nCandidates, nBad;
|
||||
struct peer_atom ** candidates = getPeerCandidates( t, &nCandidates );
|
||||
struct tr_peer ** connections = getPeersToClose( t, &nBad );
|
||||
int maxCandidates;
|
||||
|
||||
maxCandidates = nCandidates;
|
||||
maxCandidates = MAX( maxCandidates, MAX_RECONNECTIONS_PER_PULSE );
|
||||
maxCandidates = MAX( maxCandidates, getMaxPeerCount( t->tor ) - getPeerCount( t ) );
|
||||
maxCandidates = MAX( maxCandidates, MAX_CONNECTIONS_PER_SECOND - newConnectionsThisSecond );
|
||||
|
||||
//if( nBad || nCandidates )
|
||||
tordbg( t, "reconnect pulse for [%s]: %d bad connections, "
|
||||
|
@ -2220,11 +2226,11 @@ reconnectPulse( void * vtorrent )
|
|||
tr_ptrArraySize( &t->pool ),
|
||||
(int)MAX_RECONNECTIONS_PER_PULSE );
|
||||
|
||||
/* disconnect some peers.
|
||||
/* disconnect some peers to make room for better ones.
|
||||
if we transferred piece data, then they might be good peers,
|
||||
so reset their `numFails' weight to zero. otherwise we connected
|
||||
to them fruitlessly, so mark it as another fail */
|
||||
for( i = 0; i < nBad; ++i ) {
|
||||
for( i = 0; ( i < nBad ) && ( i < maxCandidates ) ; ++i ) {
|
||||
tr_peer * peer = connections[i];
|
||||
struct peer_atom * atom = getExistingAtom( t, &peer->addr );
|
||||
if( atom->piece_data_time )
|
||||
|
|
Loading…
Reference in a new issue