Changeset 9514
- Timestamp:
- Nov 10, 2009, 5:26:04 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-msgs.c
r9513 r9514 173 173 int desiredRequestCount; 174 174 175 int prefetchCount; 176 175 177 /* how long the outMessages batch should be allowed to grow before 176 178 * it's flushed -- some messages (like requests >:) should be sent … … 198 200 struct peer_request peerAskedFor[REQQ]; 199 201 int peerAskedForCount; 200 202 201 203 tr_pex * pex; 202 204 tr_pex * pex6; … … 837 839 tr_bencDictAddRaw( &val, "ipv6", ipv6, 16 ); 838 840 tr_bencDictAddInt( &val, "p", tr_sessionGetPeerPort( getSession(msgs) ) ); 839 tr_bencDictAddInt( &val, "reqq", REQQ ); 841 tr_bencDictAddInt( &val, "reqq", REQQ ); 840 842 tr_bencDictAddInt( &val, "upload_only", tr_torrentIsSeed( msgs->torrent ) ); 841 843 tr_bencDictAddStr( &val, "v", TR_NAME " " USERAGENT_PREFIX ); … … 1557 1559 double rate; 1558 1560 const int floor = 16; 1559 const int seconds = REQUEST_BUF_SECS; 1561 const int seconds = REQUEST_BUF_SECS; 1560 1562 1561 1563 /* Get the rate limit we should use. … … 1595 1597 tr_block_index_t * blocks = tr_new( tr_block_index_t, numwant ); 1596 1598 1597 tr_peerMgrGetNextRequests( msgs->torrent, msgs->peer, numwant, blocks, &n ); 1599 tr_peerMgrGetNextRequests( msgs->torrent, msgs->peer, numwant, blocks, &n ); 1598 1600 1599 1601 for( i=0; i<n; ++i ) … … 1607 1609 1608 1610 tr_free( blocks ); 1611 } 1612 } 1613 1614 static void 1615 prefetchPieces( tr_peermsgs *msgs ) 1616 { 1617 int i; 1618 uint64_t next = 0; 1619 1620 /* Maintain at least 8 prefetched blocks per unchoked peer, but allow 1621 up to 4 extra blocks if that would cause sequential writes. */ 1622 for( i=msgs->prefetchCount; i<msgs->peerAskedForCount; ++i ) 1623 { 1624 const struct peer_request * req = msgs->peerAskedFor + i; 1625 const uint64_t begin = tr_pieceOffset( msgs->torrent, req->index, req->offset, 0 ); 1626 const uint64_t end = begin + req->length; 1627 const tr_bool isSequential = next == begin; 1628 1629 if( ( i >= 12 ) || ( !isSequential && ( i >= 8 ) ) ) 1630 break; 1631 1632 tr_ioPrefetch( msgs->torrent, req->index, req->offset, req->length ); 1633 ++msgs->prefetchCount; 1634 1635 next = end; 1609 1636 } 1610 1637 } … … 1646 1673 && popNextRequest( msgs, &req ) ) 1647 1674 { 1675 --msgs->prefetchCount; 1676 1648 1677 if( requestIsValid( msgs, &req ) 1649 1678 && tr_cpPieceIsComplete( &msgs->torrent->completion, req.index ) ) … … 1691 1720 protocolSendReject( msgs, &req ); 1692 1721 } 1722 1723 prefetchPieces( msgs ); 1693 1724 } 1694 1725
Note: See TracChangeset
for help on using the changeset viewer.