Changeset 9529


Ignore:
Timestamp:
Nov 19, 2009, 3:00:20 AM (12 years ago)
Author:
charles
Message:

(trunk libT) #2589: unnecessary calls to time() cause high CPU load

File:
1 edited

Legend:

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

    r9501 r9529  
    23252325shouldPeerBeClosed( const Torrent    * t,
    23262326                    const tr_peer    * peer,
    2327                     int                peerCount )
     2327                    int                peerCount,
     2328                    const time_t       now )
    23282329{
    23292330    const tr_torrent *       tor = t->tor;
    2330     const time_t             now = time( NULL );
    23312331    const struct peer_atom * atom = peer->atom;
    23322332
     
    23952395    tr_peer ** peers = (tr_peer**) tr_ptrArrayPeek( &t->peers, &peerCount );
    23962396    struct tr_peer ** ret = tr_new( tr_peer *, peerCount );
     2397    const time_t now = time( NULL );
    23972398
    23982399    assert( torrentIsLocked( t ) );
    23992400
    24002401    for( i = outsize = 0; i < peerCount; ++i )
    2401         if( shouldPeerBeClosed( t, peers[i], peerCount ) == closeType )
     2402        if( shouldPeerBeClosed( t, peers[i], peerCount, now ) == closeType )
    24022403            ret[outsize++] = peers[i];
    24032404
     
    24392440
    24402441static int
    2441 getReconnectIntervalSecs( const struct peer_atom * atom )
    2442 {
    2443     int          sec;
    2444     const time_t now = time( NULL );
     2442getReconnectIntervalSecs( const struct peer_atom * atom, const time_t now )
     2443{
     2444    int sec;
    24452445
    24462446    /* if we were recently connected to this peer and transferring piece
     
    25082508
    25092509        /* don't reconnect too often */
    2510         interval = getReconnectIntervalSecs( atom );
     2510        interval = getReconnectIntervalSecs( atom, now );
    25112511        if( ( now - atom->time ) < interval )
    25122512        {
Note: See TracChangeset for help on using the changeset viewer.