Don't want conns for seeding unless we have a piece

This commit is contained in:
Matt Joiner 2021-11-28 22:40:53 +11:00
parent 51f6f07633
commit f621f0f5a8
1 changed files with 4 additions and 3 deletions

View 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) {