From: Matt Joiner Date: Tue, 12 Jun 2018 10:17:15 +0000 (+1000) Subject: Fix crash adding peers when Torrent is closed X-Git-Tag: v1.0.0~127^2~40 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=a287d069a447cb7ac18eedcb3b213f70c24329da;p=btrtrc.git Fix crash adding peers when Torrent is closed --- diff --git a/torrent.go b/torrent.go index 99b71ae4..9b3ff31e 100644 --- a/torrent.go +++ b/torrent.go @@ -249,6 +249,9 @@ func (t *Torrent) unclosedConnsAsSlice() (ret []*connection) { func (t *Torrent) addPeer(p Peer) { cl := t.cl peersAddedBySource.Add(string(p.Source), 1) + if t.closed.IsSet() { + return + } if cl.badPeerIPPort(p.IP, p.Port) { torrent.Add("peers not added because of bad addr", 1) return