]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Make readahead always at least 2 blocks.
authorMatt Joiner <anacrolix@gmail.com>
Tue, 16 Jun 2015 06:54:12 +0000 (16:54 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 16 Jun 2015 06:54:12 +0000 (16:54 +1000)
client.go

index 2d6bbab559f4ad0479ecf35e7b21251e4fb192f2..1f11990051f8a0aa21fece170c9690387d127e5f 100644 (file)
--- a/client.go
+++ b/client.go
@@ -275,8 +275,12 @@ again:
 
 // Calculates the number of pieces to set to Readahead priority, after the
 // Now, and Next pieces.
-func readaheadPieces(readahead, pieceLength int64) int {
-       return int((readahead+pieceLength-1)/pieceLength - 1)
+func readaheadPieces(readahead, pieceLength int64) (ret int) {
+       ret = int((readahead+pieceLength-1)/pieceLength - 1)
+       if ret < 2 {
+               ret = 2
+       }
+       return
 }
 
 func (cl *Client) readRaisePiecePriorities(t *torrent, off, readaheadBytes int64) {