]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Improve logging heuristic for sending chunks of pieces that go missing
authorMatt Joiner <anacrolix@gmail.com>
Wed, 6 Jul 2016 04:03:11 +0000 (14:03 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 6 Jul 2016 04:03:11 +0000 (14:03 +1000)
client.go

index f8c42bebf4ea29d89311a77341a144d56beda9e1..2507e69c14b67d0dc885d492855f5bf6374efc4a 100644 (file)
--- 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