Ignore:
Timestamp:
Nov 8, 2007, 4:11:09 AM (15 years ago)
Author:
charles
Message:
  • some work on lessening the way we hammer the router.
  • move strlcpy and strlcat out of their own files and into utils.c
File:
1 edited

Legend:

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

    r3753 r3755  
    914914    if( !ok || !t || !t->isRunning )
    915915    {
     916        if( t ) {
     917            struct peer_atom * atom = getExistingAtom( t, addr );
     918            if( atom )
     919                ++atom->numFails;
     920        }
     921
    916922        tr_peerIoFree( io );
    917923    }
     
    15841590
    15851591static int
    1586 compareAtomByTime( const void * va, const void * vb )
     1592compareCandidates( const void * va, const void * vb )
    15871593{
    15881594    const struct peer_atom * a = * (const struct peer_atom**) va;
    15891595    const struct peer_atom * b = * (const struct peer_atom**) vb;
    1590     if( a->time < b->time ) return -1;
    1591     if( a->time > b->time ) return 1;
     1596    int i;
     1597
     1598    if(( i = tr_compareUint16( a->numFails, b->numFails )))
     1599        return i;
     1600
     1601    if( a->time != b->time )
     1602        return a->time < b->time ? -1 : 1;
     1603
    15921604    return 0;
    15931605}
     
    16331645        }
    16341646
     1647        /* we're wasting our time trying to connect to this bozo. */
     1648        if( atom->numFails > 10 ) {
     1649            tordbg( t, "RECONNECT peer %d (%s) gives us nothing but failure.",
     1650                    i, tr_peerIoAddrStr(&atom->addr,atom->port) );
     1651            continue;
     1652        }
     1653
    16351654        /* if we used this peer recently, give someone else a turn */
    1636         minWait = 60; /* one minute */
    1637         maxWait = (60 * 10); /* ten minutes */
    1638         wait = atom->numFails * 15; /* add 15 secs to the wait interval for each consecutive failure*/
     1655        minWait = 10; /* ten seconds */
     1656        maxWait = (60 * 20); /* twenty minutes */
     1657        wait = atom->numFails * 30; /* add 15 secs to the wait interval for each consecutive failure*/
    16391658        if( wait < minWait ) wait = minWait;
    16401659        if( wait > maxWait ) wait = maxWait;
     
    16481667    }
    16491668
    1650     qsort( ret, retCount, sizeof(struct peer_atom*), compareAtomByTime );
     1669    qsort( ret, retCount, sizeof(struct peer_atom*), compareCandidates );
    16511670    *setmeSize = retCount;
    16521671    return ret;
Note: See TracChangeset for help on using the changeset viewer.