Hold rmut read lock when looking at nodeStatRefs

This commit is contained in:
Jakob Borg 2014-08-31 13:48:43 +02:00
parent 75b26513e1
commit cf1bfdfb61

View File

@ -209,9 +209,11 @@ func (m *Model) ConnectionStats() map[string]ConnectionInfo {
// Returns statistics about each node // Returns statistics about each node
func (m *Model) NodeStatistics() map[string]stats.NodeStatistics { func (m *Model) NodeStatistics() map[string]stats.NodeStatistics {
var res = make(map[string]stats.NodeStatistics) var res = make(map[string]stats.NodeStatistics)
m.rmut.RLock()
for _, node := range m.cfg.Nodes { for _, node := range m.cfg.Nodes {
res[node.NodeID.String()] = m.nodeStatRefs[node.NodeID].GetStatistics() res[node.NodeID.String()] = m.nodeStatRefs[node.NodeID].GetStatistics()
} }
m.rmut.RUnlock()
return res return res
} }