From: Matt Joiner Date: Tue, 16 Jun 2015 06:54:12 +0000 (+1000) Subject: Make readahead always at least 2 blocks. X-Git-Tag: v1.0.0~1153 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=764f5db512fb41b188871b3a1b730a3cb4191b95;p=btrtrc.git Make readahead always at least 2 blocks. --- diff --git a/client.go b/client.go index 2d6bbab5..1f119900 100644 --- 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) {