]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix in decPieceAvailability when we don't have torrent info
authorMatt Joiner <anacrolix@gmail.com>
Sun, 16 May 2021 23:08:39 +0000 (09:08 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 7 Jun 2021 03:01:39 +0000 (13:01 +1000)
Happens when we close a Peer before getting Torrent info.

torrent.go

index 70e4ecd8d81addf1e86d68d8d4185b70ecda91ef..da71ba93168be13f1b5394edb267f3eea197474c 100644 (file)
@@ -158,6 +158,9 @@ func (t *Torrent) pieceAvailabilityFromPeers(i pieceIndex) (count int) {
 }
 
 func (t *Torrent) decPieceAvailability(i pieceIndex) {
+       if !t.haveInfo() {
+               return
+       }
        p := t.piece(i)
        if p.availability <= 0 {
                panic(p.availability)