From: Matt Joiner Date: Sun, 28 Nov 2021 11:40:53 +0000 (+1100) Subject: Don't want conns for seeding unless we have a piece X-Git-Tag: v1.39.0~41 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=f621f0f5a842ae23381af15e83d3799915f392a2;p=btrtrc.git Don't want conns for seeding unless we have a piece --- diff --git a/torrent.go b/torrent.go index 2cf05b68..244d3281 100644 --- a/torrent.go +++ b/torrent.go @@ -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) {