Changeset 7320


Ignore:
Timestamp:
Dec 8, 2008, 8:23:10 PM (13 years ago)
Author:
charles
Message:

(libT) #1577: honor the peer's BEP 10 reqq key, if they provide it.

File:
1 edited

Legend:

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

    r7289 r7320  
    307307
    308308    tr_pex *              pex;
     309
     310    /* if the peer supports the Extension Protocol in BEP 10 and
     311       supplied a reqq argument, it's stored here.  otherwise the
     312       value is zero and should be ignored. */
     313    int64_t               reqq;
    309314};
    310315
     
    11451150        dbgmsg( msgs, "msgs->port is now %hu", msgs->info->port );
    11461151    }
     1152
     1153    /* get peer's maximum request queue size */
     1154    if( tr_bencDictFindInt( &val, "reqq", &i ) )
     1155        msgs->reqq = i;
    11471156
    11481157    tr_bencFree( &val );
     
    17231732
    17241733static int
    1725 ratePulse( void * vpeer )
    1726 {
    1727     tr_peermsgs * peer = vpeer;
    1728     const double rateToClient = tr_peerGetPieceSpeed( peer->info,
    1729                                                       TR_PEER_TO_CLIENT );
     1734ratePulse( void * vmsgs )
     1735{
     1736    tr_peermsgs * msgs = vmsgs;
     1737    const double rateToClient = tr_peerGetPieceSpeed( msgs->info, TR_PEER_TO_CLIENT );
    17301738    const int estimatedBlocksInNext30Seconds =
    1731                   ( rateToClient * 30 * 1024 ) / peer->torrent->blockSize;
    1732 
    1733     peer->minActiveRequests = 8;
    1734     peer->maxActiveRequests = peer->minActiveRequests + estimatedBlocksInNext30Seconds;
     1739                  ( rateToClient * 30 * 1024 ) / msgs->torrent->blockSize;
     1740    msgs->minActiveRequests = 8;
     1741    msgs->maxActiveRequests = msgs->minActiveRequests + estimatedBlocksInNext30Seconds;
     1742    if( msgs->reqq > 0 )
     1743        msgs->maxActiveRequests = MIN( msgs->maxActiveRequests, msgs->reqq );
    17351744    return TRUE;
    17361745}
Note: See TracChangeset for help on using the changeset viewer.