]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Don't want conns for seeding unless we have a piece
authorMatt Joiner <anacrolix@gmail.com>
Sun, 28 Nov 2021 11:40:53 +0000 (22:40 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 28 Nov 2021 11:40:53 +0000 (22:40 +1100)
torrent.go

index 2cf05b6863a2ab2abca2a6e1cda6be6da7f56a7a..244d3281b06f140c24266002cb1cdb53aa7824a2 100644 (file)
@@ -1223,6 +1223,7 @@ func (t *Torrent) updatePieceCompletion(piece pieceIndex) bool {
        x := uint32(piece)
        if complete {
                t._completedPieces.Add(x)
+               t.openNewConns()
        } else {
                t._completedPieces.Remove(x)
        }
@@ -1811,13 +1812,13 @@ func (t *Torrent) wantConns() bool {
        if t.closed.IsSet() {
                return false
        }
-       if !t.seeding() && !t.needData() {
+       if len(t.conns) >= t.maxEstablishedConns && t.worstBadConn() == nil {
                return false
        }
-       if len(t.conns) < t.maxEstablishedConns {
+       if t.seeding() && t.haveAnyPieces() {
                return true
        }
-       return t.worstBadConn() != nil
+       return t.needData()
 }
 
 func (t *Torrent) SetMaxEstablishedConns(max int) (oldMax int) {