torrent.KnownSwarm: keep client lock when iterating over connections (#893)

This commit is contained in:
Oleg Guba 2024-01-17 03:06:31 -08:00 committed by GitHub
parent 867996b876
commit 192f4e8f7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 0 deletions

View 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,