]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix race condition in Client.ListenAddrs
authorMatt Joiner <anacrolix@gmail.com>
Wed, 13 Jun 2018 00:53:38 +0000 (10:53 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 13 Jun 2018 00:53:38 +0000 (10:53 +1000)
client.go

index f88766ea8c1a9f476982cabed0ee1c35f855c1ab..4ccdc1f98dada77739b2bd0ed1116caf935ae8d1 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1231,6 +1231,8 @@ func (cl *Client) publicAddr(peer net.IP) ipPort {
 }
 
 func (cl *Client) ListenAddrs() (ret []net.Addr) {
+       cl.mu.Lock()
+       defer cl.mu.Unlock()
        cl.eachListener(func(l socket) bool {
                ret = append(ret, l.Addr())
                return true