From 1ca2e7e95a8899bccca4f15ab6bd85863ff3f80b Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 30 Jul 2016 00:41:45 +1000 Subject: [PATCH] Add some extra conditions to prevent network activity when a torrent is closed From suggestions by @axet, this might be a thing sometimes. --- torrent.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/torrent.go b/torrent.go index da0c92bb..dd3a83cf 100644 --- a/torrent.go +++ b/torrent.go @@ -1066,6 +1066,9 @@ func (t *Torrent) readerPieces() (ret bitmap.Bitmap) { } func (t *Torrent) needData() bool { + if t.closed.IsSet() { + return false + } if !t.haveInfo() { return true } @@ -1168,6 +1171,9 @@ func (t *Torrent) updateWantPeersEvent() { // Returns whether the client should make effort to seed the torrent. func (t *Torrent) seeding() bool { cl := t.cl + if t.closed.IsSet() { + return false + } if cl.config.NoUpload { return false } @@ -1351,6 +1357,9 @@ func (t *Torrent) addConnection(c *connection) bool { } func (t *Torrent) wantConns() bool { + if t.closed.IsSet() { + return false + } if !t.seeding() && !t.needData() { return false }