cluster.Nodes() just needs a read lock

This commit is contained in:
Travis Turner 2019-01-18 14:49:58 -06:00
parent 8762c2a4dc
commit fc1de2dba9
No known key found for this signature in database
GPG key ID: 5734CE1B30B355DF

View file

@ -609,8 +609,8 @@ func (c *cluster) addNodeBasicSorted(node *Node) bool {
// Nodes returns a copy of the slice of nodes in the cluster. Safe for
// concurrent use, result may be modified.
func (c *cluster) Nodes() []*Node {
c.mu.Lock()
defer c.mu.Unlock()
c.mu.RLock()
defer c.mu.RUnlock()
ret := make([]*Node, len(c.nodes))
copy(ret, c.nodes)
return ret