2
0
mirror of synced 2025-02-24 14:48:27 +00:00

Improve logging heuristic for sending chunks of pieces that go missing

This commit is contained in:
Matt Joiner 2016-07-06 14:03:11 +10:00
parent cd1c1a9fed
commit 40a78b7cdd

View File

@ -1087,11 +1087,15 @@ another:
for r := range c.PeerRequests {
err := cl.sendChunk(t, c, r)
if err != nil {
if t.pieceComplete(int(r.Index)) && err == io.ErrUnexpectedEOF {
// We had the piece, but not anymore.
} else {
log.Printf("error sending chunk %+v to peer: %s", r, err)
i := int(r.Index)
if t.pieceComplete(i) {
t.updatePieceCompletion(i)
if !t.pieceComplete(i) {
// We had the piece, but not anymore.
break another
}
}
log.Printf("error sending chunk %+v to peer: %s", r, err)
// If we failed to send a chunk, choke the peer to ensure they
// flush all their requests. We've probably dropped a piece,
// but there's no way to communicate this to the peer. If they