]> Sergey Matveev's repositories - btrtrc.git/commitdiff
torrent.KnownSwarm: keep client lock when iterating over connections (#893)
authorOleg Guba <oleg.guba@gmail.com>
Wed, 17 Jan 2024 11:06:31 +0000 (03:06 -0800)
committerGitHub <noreply@github.com>
Wed, 17 Jan 2024 11:06:31 +0000 (22:06 +1100)
torrent.go

index 2d0cce2e13f210cb8edddd8dbb80ab0f88ec5262..0b1baba53c580840ff5b7a0a7c17ef1bd07bc43f 100644 (file)
@@ -245,6 +245,8 @@ func (t *Torrent) KnownSwarm() (ks []PeerInfo) {
        }
 
        // Add active peers to the list
+       t.cl.rLock()
+       defer t.cl.rUnlock()
        for conn := range t.conns {
                ks = append(ks, PeerInfo{
                        Id:     conn.PeerID,