Fix race condition in Client.ListenAddrs

This commit is contained in:
Matt Joiner 2018-06-13 10:53:38 +10:00
parent 90f84bda71
commit da4a6503c2
1 changed files with 2 additions and 0 deletions

View File

@ -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