Changeset 6549


Ignore:
Timestamp:
Aug 16, 2008, 5:12:55 AM (13 years ago)
Author:
charles
Message:

a few attempts to reduce the "router death" load: lower the total number of connections made per second. increase the intervals for reconnecting to some peers. simplify the code a bit.

File:
1 edited

Legend:

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

    r6517 r6549  
    5757
    5858    /* max # of peers to ask fer per torrent per reconnect pulse */
    59     MAX_RECONNECTIONS_PER_PULSE = 4,
     59    MAX_RECONNECTIONS_PER_PULSE = 2,
    6060
    6161    /* max number of peers to ask for per second overall.
    6262     * this throttle is to avoid overloading the router */
    63     MAX_CONNECTIONS_PER_SECOND = 8,
     63    MAX_CONNECTIONS_PER_SECOND = 4,
    6464
    6565    /* number of unchoked peers per torrent.
     
    17561756}
    17571757
     1758static int
     1759getReconnectIntervalSecs( const struct peer_atom * atom )
     1760{
     1761    int min;
     1762
     1763    switch( atom->numFails )
     1764    {
     1765        case 0:
     1766        case 1: min = 7; break;
     1767        case 2: min = 15; break;
     1768        case 3: min = 30; break;
     1769        case 4: min = 60; break;
     1770        default: min = 120; break;
     1771    }
     1772
     1773    return min * 60;
     1774}
     1775
    17581776static struct peer_atom **
    17591777getPeerCandidates( Torrent * t, int * setmeSize )
     
    17921810            continue;
    17931811
    1794         /* we're wasting our time trying to connect to this bozo. */
    1795         if( atom->numFails > 3 )
    1796             continue;
    1797 
    17981812        /* If we were connected to this peer recently and transferring
    17991813         * piece data, try to reconnect -- network troubles may have
    18001814         * disconnected us.  but if we weren't sharing piece data,
    18011815         * hold off on this peer to give another one a try instead */
    1802         if( ( now - atom->piece_data_time ) > 30 )
     1816        if( ( now - atom->piece_data_time ) > 10 )
    18031817        {
    1804             int minWait = (60 * 5); /* five minutes */
    1805             int maxWait = minWait * 3;
    1806             int wait = atom->numFails * minWait;
    1807             if( wait < minWait ) wait = minWait;
    1808             if( wait > maxWait ) wait = maxWait;
     1818            const int wait = getReconnectIntervalSecs( atom );
    18091819            if( ( now - atom->time ) < wait ) {
    18101820                tordbg( t, "RECONNECT peer %d (%s) is in its grace period of %d seconds..",
Note: See TracChangeset for help on using the changeset viewer.