Ignore:
Timestamp:
Jan 4, 2010, 10:21:58 PM (13 years ago)
Author:
charles
Message:

(1.7x libT) backport to 1.7x branch: r9529 #2589 "unnecessary calls to time() cause high CPU load"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.7x/libtransmission/peer-mgr.c

    r9090 r9872  
    21082108shouldPeerBeClosed( const Torrent    * t,
    21092109                    const tr_peer    * peer,
    2110                     int                peerCount )
     2110                    int                peerCount,
     2111                    const time_t       now )
    21112112{
    21122113    const tr_torrent *       tor = t->tor;
    2113     const time_t             now = time( NULL );
    21142114    const struct peer_atom * atom = peer->atom;
    21152115
     
    21762176    tr_peer ** peers = (tr_peer**) tr_ptrArrayPeek( &t->peers, &peerCount );
    21772177    struct tr_peer ** ret = tr_new( tr_peer *, peerCount );
     2178    const time_t now = time( NULL );
    21782179
    21792180    assert( torrentIsLocked( t ) );
    21802181
    21812182    for( i = outsize = 0; i < peerCount; ++i )
    2182         if( shouldPeerBeClosed( t, peers[i], peerCount ) == closeType )
     2183        if( shouldPeerBeClosed( t, peers[i], peerCount, now ) == closeType )
    21832184            ret[outsize++] = peers[i];
    21842185
     
    22182219
    22192220static int
    2220 getReconnectIntervalSecs( const struct peer_atom * atom )
    2221 {
    2222     int          sec;
    2223     const time_t now = time( NULL );
     2221getReconnectIntervalSecs( const struct peer_atom * atom, const time_t now )
     2222{
     2223    int sec;
    22242224
    22252225    /* if we were recently connected to this peer and transferring piece
     
    22872287
    22882288        /* don't reconnect too often */
    2289         interval = getReconnectIntervalSecs( atom );
     2289        interval = getReconnectIntervalSecs( atom, now );
    22902290        if( ( now - atom->time ) < interval )
    22912291        {
Note: See TracChangeset for help on using the changeset viewer.