Ignore:
Timestamp:
Jan 20, 2009, 3:32:54 AM (12 years ago)
Author:
charles
Message:

(trunk libT) when pruning out slow peers, don't prune if we don't have good candidates to replace them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r7740 r7761  
    20322032         * if we have zero connections, strictness is 0% */
    20332033        const float strictness = peerCount >= relaxStrictnessIfFewerThanN
    2034             ? 1.0
    2035             : peerCount / (float)relaxStrictnessIfFewerThanN;
     2034                               ? 1.0
     2035                               : peerCount / (float)relaxStrictnessIfFewerThanN;
    20362036        const int lo = MIN_UPLOAD_IDLE_SECS;
    20372037        const int hi = MAX_UPLOAD_IDLE_SECS;
     
    22132213        struct peer_atom ** candidates = getPeerCandidates( t, &nCandidates );
    22142214        struct tr_peer ** connections = getPeersToClose( t, &nBad );
     2215        int maxCandidates;
     2216
     2217        maxCandidates = nCandidates;
     2218        maxCandidates = MAX( maxCandidates, MAX_RECONNECTIONS_PER_PULSE );
     2219        maxCandidates = MAX( maxCandidates, getMaxPeerCount( t->tor ) - getPeerCount( t ) );
     2220        maxCandidates = MAX( maxCandidates, MAX_CONNECTIONS_PER_SECOND - newConnectionsThisSecond );
    22152221
    22162222        //if( nBad || nCandidates )
     
    22212227                    (int)MAX_RECONNECTIONS_PER_PULSE );
    22222228
    2223         /* disconnect some peers.
     2229        /* disconnect some peers to make room for better ones.
    22242230           if we transferred piece data, then they might be good peers,
    22252231           so reset their `numFails' weight to zero.  otherwise we connected
    22262232           to them fruitlessly, so mark it as another fail */
    2227         for( i = 0; i < nBad; ++i ) {
     2233        for( i = 0; ( i < nBad ) && ( i < maxCandidates ) ; ++i ) {
    22282234            tr_peer * peer = connections[i];
    22292235            struct peer_atom * atom = getExistingAtom( t, &peer->addr );
Note: See TracChangeset for help on using the changeset viewer.