reader.go | 5 ++++- torrent.go | 3 ++- diff --git a/reader.go b/reader.go index 42910a869ec3c8aab53ebb30fb60c0321a277054..35d3b32c57cd661c5ff6debd83207bc4d431b60e 100644 --- a/reader.go +++ b/reader.go @@ -224,8 +224,11 @@ // prevent thrashing with small caches and file and piece priorities. r.log(log.Fstr("error reading torrent %s piece %d offset %d, %d bytes: %v", r.t.infoHash.HexString(), firstPieceIndex, firstPieceOffset, len(b1), err)) if !r.t.updatePieceCompletion(firstPieceIndex) { - r.log(log.Fstr("piece %d completion unchanged", firstPieceIndex)) + r.log(log.Fstr("piece %d completion unchanged (%+v)", firstPieceIndex, r.t.piece(firstPieceIndex).completion())) } + r.t.iterPeers(func(c *Peer) { + c.updateRequests() + }) // Update the rest of the piece completions in the readahead window, without alerting to // changes (since only the first piece, the one above, could have generated the read error // we're currently handling). diff --git a/torrent.go b/torrent.go index 26f49b82a6b289a08e9526d015b5d974db90f902..66c834545cfaa5870f4d6bde6a33f545003d19d1 100644 --- a/torrent.go +++ b/torrent.go @@ -1760,13 +1760,14 @@ for c := range p.dirtiers { c._stats.incrementPiecesDirtiedGood() } t.clearPieceTouchers(piece) + p.incrementPendingWrites() t.cl.unlock() err := p.Storage().MarkComplete() if err != nil { t.logger.Printf("%T: error marking piece complete %d: %s", t.storage, piece, err) } t.cl.lock() - + p.decrementPendingWrites() if t.closed.IsSet() { return }