From: Matt Joiner Date: Thu, 11 Sep 2014 04:22:29 +0000 (+1000) Subject: Tighten responsive download strategy partial piece request filling X-Git-Tag: v1.0.0~1571 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=5d35e10706dd1a3f39299c26de2b1e89c8cdf975;p=btrtrc.git Tighten responsive download strategy partial piece request filling --- diff --git a/download_strategies.go b/download_strategies.go index a71618d0..0c3af687 100644 --- a/download_strategies.go +++ b/download_strategies.go @@ -219,21 +219,22 @@ func (me *requestFiller) completePartial() bool { th := me.s.requestHeat[t] for e := t.IncompletePiecesByBytesLeft.Front(); e != nil; e = e.Next() { p := e.Value.(int) + // Stop when we reach pieces that aren't partial and aren't smaller + // than usual. if !t.PiecePartiallyDownloaded(p) && int(t.PieceLength(pp.Integer(p))) == t.UsualPieceSize() { break } - if lastReadOffset, ok := me.s.lastReadOffset[t]; ok { - if p >= int(lastReadOffset/int64(t.UsualPieceSize())) { - if int64(p+1)*int64(t.UsualPieceSize()) < lastReadOffset+me.s.Readahead { - continue - } - } - } for chunkSpec := range t.Pieces[p].PendingChunkSpecs { r := request{pp.Integer(p), chunkSpec} if th[r] >= 1 { continue } + if lastReadOffset, ok := me.s.lastReadOffset[t]; ok { + off := me.t.requestOffset(r) + if off >= lastReadOffset && off < lastReadOffset+me.s.Readahead { + continue + } + } if !me.conservativelyRequest(r) { return false }