From da4a6503c22c61aabc78fdd1f48e6cf097956a0d Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 13 Jun 2018 10:53:38 +1000 Subject: [PATCH] Fix race condition in Client.ListenAddrs --- client.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client.go b/client.go index f88766ea..4ccdc1f9 100644 --- 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