diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c
index b43397f..7233f63 100644
a
|
b
|
updatePeerProgress( tr_peermsgs * msgs ) |
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | static void |
| 1116 | prefetchPieces( tr_peermsgs *msgs ) |
| 1117 | { |
| 1118 | int i; |
| 1119 | uint64_t next = 0; |
| 1120 | |
| 1121 | /* Maintain at least 8 prefetched blocks per unchoked peer, but allow |
| 1122 | up to 4 extra blocks if that would cause sequential writes. */ |
| 1123 | for( i=msgs->prefetchCount; i<msgs->peerAskedForCount; ++i ) |
| 1124 | { |
| 1125 | const struct peer_request * req = msgs->peerAskedFor + i; |
| 1126 | const uint64_t begin = tr_pieceOffset( msgs->torrent, req->index, req->offset, 0 ); |
| 1127 | const uint64_t end = begin + req->length; |
| 1128 | const tr_bool isSequential = next == begin; |
| 1129 | |
| 1130 | if( ( i >= 12 ) || ( !isSequential && ( i >= 8 ) ) ) |
| 1131 | break; |
| 1132 | |
| 1133 | tr_ioPrefetch( msgs->torrent, req->index, req->offset, req->length ); |
| 1134 | ++msgs->prefetchCount; |
| 1135 | |
| 1136 | next = end; |
| 1137 | } |
| 1138 | } |
| 1139 | |
| 1140 | static void |
1116 | 1141 | peerMadeRequest( tr_peermsgs * msgs, |
1117 | 1142 | const struct peer_request * req ) |
1118 | 1143 | { |
… |
… |
peerMadeRequest( tr_peermsgs * msgs, |
1134 | 1159 | else |
1135 | 1160 | allow = TRUE; |
1136 | 1161 | |
1137 | | if( allow ) |
| 1162 | if( allow ) { |
1138 | 1163 | msgs->peerAskedFor[msgs->peerAskedForCount++] = *req; |
1139 | | else if( fext ) |
| 1164 | prefetchPieces( msgs ); |
| 1165 | } else if( fext ) |
1140 | 1166 | protocolSendReject( msgs, req ); |
1141 | 1167 | } |
1142 | 1168 | |
… |
… |
updateRequests( tr_peermsgs * msgs ) |
1633 | 1659 | } |
1634 | 1660 | } |
1635 | 1661 | |
1636 | | static void |
1637 | | prefetchPieces( tr_peermsgs *msgs ) |
1638 | | { |
1639 | | int i; |
1640 | | uint64_t next = 0; |
1641 | | |
1642 | | /* Maintain at least 8 prefetched blocks per unchoked peer, but allow |
1643 | | up to 4 extra blocks if that would cause sequential writes. */ |
1644 | | for( i=msgs->prefetchCount; i<msgs->peerAskedForCount; ++i ) |
1645 | | { |
1646 | | const struct peer_request * req = msgs->peerAskedFor + i; |
1647 | | const uint64_t begin = tr_pieceOffset( msgs->torrent, req->index, req->offset, 0 ); |
1648 | | const uint64_t end = begin + req->length; |
1649 | | const tr_bool isSequential = next == begin; |
1650 | | |
1651 | | if( ( i >= 12 ) || ( !isSequential && ( i >= 8 ) ) ) |
1652 | | break; |
1653 | | |
1654 | | tr_ioPrefetch( msgs->torrent, req->index, req->offset, req->length ); |
1655 | | ++msgs->prefetchCount; |
1656 | | |
1657 | | next = end; |
1658 | | } |
1659 | | } |
1660 | | |
1661 | 1662 | static size_t |
1662 | 1663 | fillOutputBuffer( tr_peermsgs * msgs, time_t now ) |
1663 | 1664 | { |