From: Matt Joiner Date: Wed, 6 Jul 2016 04:03:11 +0000 (+1000) Subject: Improve logging heuristic for sending chunks of pieces that go missing X-Git-Tag: v1.0.0~660 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=40a78b7cdd096f5252a746a2e80318e2a199b428;p=btrtrc.git Improve logging heuristic for sending chunks of pieces that go missing --- 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