Changeset 6964


Ignore:
Timestamp:
Oct 27, 2008, 4:12:42 AM (12 years ago)
Author:
charles
Message:

(libT) eliminate some duplicate calls to time(NULL) that showed a spike on vraa & softwareelves' shark profiles

File:
1 edited

Legend:

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

    r6954 r6964  
    598598                     int           choke )
    599599{
    600     const time_t fibrillationTime = time( NULL ) - MIN_CHOKE_PERIOD_SEC;
     600    const time_t now = time( NULL );
     601    const time_t fibrillationTime = now - MIN_CHOKE_PERIOD_SEC;
    601602
    602603    assert( msgs );
     
    615616            cancelAllRequestsToClientExceptFast( msgs );
    616617        protocolSendChoke( msgs, choke );
    617         msgs->info->chokeChangedAt = time( NULL );
     618        msgs->info->chokeChangedAt = now;
    618619    }
    619620}
     
    768769
    769770static void
    770 expireOldRequests( tr_peermsgs * msgs )
     771expireOldRequests( tr_peermsgs * msgs, const time_t now )
    771772{
    772773    int                 i;
     
    775776
    776777    /* cancel requests that have been queued for too long */
    777     oldestAllowed = time( NULL ) - QUEUED_REQUEST_TTL_SECS;
     778    oldestAllowed = now - QUEUED_REQUEST_TTL_SECS;
    778779    reqListCopy( &tmp, &msgs->clientWillAskFor );
    779780    for( i = 0; i < tmp.count; ++i )
     
    786787
    787788    /* cancel requests that were sent too long ago */
    788     oldestAllowed = time( NULL ) - SENT_REQUEST_TTL_SECS;
     789    oldestAllowed = now - SENT_REQUEST_TTL_SECS;
    789790    reqListCopy( &tmp, &msgs->clientAskedFor );
    790791    for( i = 0; i < tmp.count; ++i )
     
    798799
    799800static void
    800 pumpRequestQueue( tr_peermsgs * msgs )
     801pumpRequestQueue( tr_peermsgs * msgs, const time_t now )
    801802{
    802803    const int           max = msgs->maxActiveRequests;
    803804    const int           min = msgs->minActiveRequests;
    804     const time_t        now = time( NULL );
    805805    int                 sent = 0;
    806806    int                 count = msgs->clientAskedFor.count;
     
    15361536static void
    15371537peerGotBytes( tr_peermsgs * msgs,
    1538               uint32_t      byteCount )
    1539 {
    1540     msgs->info->pieceDataActivityDate = time( NULL );
     1538              uint32_t      byteCount,
     1539              const time_t  now )
     1540{
     1541    msgs->info->pieceDataActivityDate = now;
    15411542    firePeerGotData( msgs, byteCount );
    15421543}
     
    17071708
    17081709    /*tr_peerIoTryRead( msgs->io );*/
    1709     pumpRequestQueue( msgs );
    1710     expireOldRequests( msgs );
     1710    pumpRequestQueue( msgs, now );
     1711    expireOldRequests( msgs, now );
    17111712
    17121713    if( msgs->sendingBlock )
     
    17201721        if( outlen )
    17211722        {
    1722             tr_peerIoWrite( msgs->io, EVBUFFER_DATA(
    1723                                 msgs->outBlock ), outlen );
     1723            tr_peerIoWrite( msgs->io, EVBUFFER_DATA( msgs->outBlock ), outlen );
    17241724            evbuffer_drain( msgs->outBlock, outlen );
    1725             peerGotBytes( msgs, outlen );
     1725            peerGotBytes( msgs, outlen, now );
    17261726
    17271727            len -= outlen;
     
    17341734        else dbgmsg( msgs,
    17351735                     "stalled writing block... uploadMax %lu, outlen %lu",
    1736                      uploadMax,
    1737                      outlen );
     1736                     uploadMax, outlen );
    17381737    }
    17391738
     
    17411740    {
    17421741        struct peer_request req;
    1743         int                 haveMessages = EVBUFFER_LENGTH(
    1744             msgs->outMessages ) != 0;
     1742        const int haveMessages = EVBUFFER_LENGTH( msgs->outMessages ) != 0;
    17451743
    17461744        if( haveMessages && !msgs->outMessagesBatchedAt ) /* fresh batch */
Note: See TracChangeset for help on using the changeset viewer.