]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix crash adding peers when Torrent is closed
authorMatt Joiner <anacrolix@gmail.com>
Tue, 12 Jun 2018 10:17:15 +0000 (20:17 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 12 Jun 2018 10:17:15 +0000 (20:17 +1000)
torrent.go

index 99b71ae4f3d585cbd8033a7a7833dad4a7a145f2..9b3ff31e82aea1cdf01770b617045998d39aabfd 100644 (file)
@@ -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