webseed-requesting.go | 9 +++++++-- diff --git a/webseed-requesting.go b/webseed-requesting.go index 0c208b481c19121ca2aab4e85a6a3709014f9dfb..f158650e32fa91238d108cf3afb2d203b0064d9e 100644 --- a/webseed-requesting.go +++ b/webseed-requesting.go @@ -197,6 +197,7 @@ } // Cancel any existing requests that are no longer wanted. for _, value := range unwantedExistingRequests { + // Should we skip cancelling requests that are ended and just haven't cleaned up yet? value.existingWebseedRequest.Cancel("deprioritized") } @@ -446,7 +447,11 @@ // slots waiting to cancel from conflicting. return true } } - p := t.piece(t.pieceIndexOfRequestIndex(ar.next)) + priority := PiecePriorityNone + if ar.next < ar.end { + p := t.piece(t.pieceIndexOfRequestIndex(ar.next)) + priority = p.effectivePriority() + } return yield( webseedUniqueRequestKey{ t: t, @@ -455,7 +460,7 @@ url: url, }, webseedRequestOrderValue{ aprioriMapValue{ - priority: p.effectivePriority(), + priority: priority, costKey: hostKey, startRequest: ar.next, },