mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 16:37:04 +08:00
Use RLock instead of Lock
This commit is contained in:
@@ -686,9 +686,9 @@ func (c *cluster) IsClusterDegraded() (bool, error) {
|
|||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
|
|
||||||
c.nodesLock.Lock()
|
c.nodesLock.RLock()
|
||||||
nodes := len(c.nodes)
|
nodes := len(c.nodes)
|
||||||
c.nodesLock.Unlock()
|
c.nodesLock.RUnlock()
|
||||||
|
|
||||||
if len(servers) != nodes {
|
if len(servers) != nodes {
|
||||||
return true, fmt.Errorf("not all nodes are connected")
|
return true, fmt.Errorf("not all nodes are connected")
|
||||||
@@ -1391,7 +1391,7 @@ func (c *cluster) About() (ClusterAbout, error) {
|
|||||||
serversMap[s.ID] = s
|
serversMap[s.ID] = s
|
||||||
}
|
}
|
||||||
|
|
||||||
c.nodesLock.Lock()
|
c.nodesLock.RLock()
|
||||||
for id, node := range c.nodes {
|
for id, node := range c.nodes {
|
||||||
nodeAbout := node.About()
|
nodeAbout := node.About()
|
||||||
|
|
||||||
@@ -1435,7 +1435,7 @@ func (c *cluster) About() (ClusterAbout, error) {
|
|||||||
|
|
||||||
about.Nodes = append(about.Nodes, node)
|
about.Nodes = append(about.Nodes, node)
|
||||||
}
|
}
|
||||||
c.nodesLock.Unlock()
|
c.nodesLock.RUnlock()
|
||||||
|
|
||||||
return about, nil
|
return about, nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user