]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Log errant unwanted piece rather than panic
authorMatt Joiner <anacrolix@gmail.com>
Mon, 3 Aug 2015 15:29:40 +0000 (01:29 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 3 Aug 2015 15:29:40 +0000 (01:29 +1000)
Eventually I'll work out what causes this, but for now it's incredibly rare.

client.go

index ec3f94dcfa0457dca4c8de1c7b10915d6e0520d2..8760c283944f81b0adc5a5c60846404466e842e1 100644 (file)
--- a/client.go
+++ b/client.go
@@ -2480,7 +2480,9 @@ func (me *Client) fillRequests(t *torrent, c *connection) {
                        panic("piece in request order but peer doesn't have it")
                }
                if !t.wantPiece(pieceIndex) {
-                       panic("unwanted piece in connection request order")
+                       log.Printf("unwanted piece %d in connection request order\n%s", pieceIndex, c)
+                       c.pieceRequestOrder.DeletePiece(pieceIndex)
+                       continue
                }
                piece := t.Pieces[pieceIndex]
                for _, cs := range piece.shuffledPendingChunkSpecs(t.pieceLength(pieceIndex), pp.Integer(t.chunkSize)) {