client.go | 15 ++++++++------- diff --git a/client.go b/client.go index e86a93a96df412566210be74e4eecd7675ba51d8..fc4d48ff84bab1cbec02448f94b9a286516209a7 100644 --- a/client.go +++ b/client.go @@ -856,13 +856,6 @@ return err } me.dataReady(dataSpec{t.InfoHash, req}) - // Cancel pending requests for this chunk. - for _, c := range t.Conns { - if me.connCancel(t, c, req) { - me.replenishConnRequests(t, c) - } - } - // Record that we have the chunk. delete(t.Pieces[req.Index].PendingChunkSpecs, req.chunkSpec) if len(t.Pieces[req.Index].PendingChunkSpecs) == 0 { @@ -875,6 +868,14 @@ for e := t.Priorities.Front(); e != nil; e = next { next = e.Next() if e.Value.(request) == req { t.Priorities.Remove(e) + } + } + + // Cancel pending requests for this chunk. + for _, c := range t.Conns { + if me.connCancel(t, c, req) { + log.Print("cancelled concurrent request for %s", req) + me.replenishConnRequests(t, c) } }