From 40a78b7cdd096f5252a746a2e80318e2a199b428 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 6 Jul 2016 14:03:11 +1000 Subject: [PATCH] Improve logging heuristic for sending chunks of pieces that go missing --- client.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index f8c42beb..2507e69c 100644 --- a/client.go +++ b/client.go @@ -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 -- 2.50.0