torrent.go | 7 ++++--- diff --git a/torrent.go b/torrent.go index 2cf05b6863a2ab2abca2a6e1cda6be6da7f56a7a..244d3281b06f140c24266002cb1cdb53aa7824a2 100644 --- a/torrent.go +++ b/torrent.go @@ -1223,6 +1223,7 @@ p.storageCompletionOk = uncached.Ok x := uint32(piece) if complete { t._completedPieces.Add(x) + t.openNewConns() } else { t._completedPieces.Remove(x) } @@ -1811,13 +1812,13 @@ } 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) {