Fix stalls for responsive transfer tests
Looks like there's a timing issue between marking things complete, and already having decided to read the data from incomplete chunks.
This commit is contained in:
parent
270a2ba1ae
commit
d48c6ae6dc
|
@ -224,8 +224,11 @@ func (r *reader) readOnceAt(b []byte, pos int64, ctxErr *error) (n int, err erro
|
||||||
r.log(log.Fstr("error reading torrent %s piece %d offset %d, %d bytes: %v",
|
r.log(log.Fstr("error reading torrent %s piece %d offset %d, %d bytes: %v",
|
||||||
r.t.infoHash.HexString(), firstPieceIndex, firstPieceOffset, len(b1), err))
|
r.t.infoHash.HexString(), firstPieceIndex, firstPieceOffset, len(b1), err))
|
||||||
if !r.t.updatePieceCompletion(firstPieceIndex) {
|
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
|
// 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
|
// changes (since only the first piece, the one above, could have generated the read error
|
||||||
// we're currently handling).
|
// we're currently handling).
|
||||||
|
|
|
@ -1760,13 +1760,14 @@ func (t *Torrent) pieceHashed(piece pieceIndex, passed bool, hashIoErr error) {
|
||||||
c._stats.incrementPiecesDirtiedGood()
|
c._stats.incrementPiecesDirtiedGood()
|
||||||
}
|
}
|
||||||
t.clearPieceTouchers(piece)
|
t.clearPieceTouchers(piece)
|
||||||
|
p.incrementPendingWrites()
|
||||||
t.cl.unlock()
|
t.cl.unlock()
|
||||||
err := p.Storage().MarkComplete()
|
err := p.Storage().MarkComplete()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.logger.Printf("%T: error marking piece complete %d: %s", t.storage, piece, err)
|
t.logger.Printf("%T: error marking piece complete %d: %s", t.storage, piece, err)
|
||||||
}
|
}
|
||||||
t.cl.lock()
|
t.cl.lock()
|
||||||
|
p.decrementPendingWrites()
|
||||||
if t.closed.IsSet() {
|
if t.closed.IsSet() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue