diff --git a/meshviewer/graph.go b/meshviewer/graph.go index dda0d3a..b3ddd84 100644 --- a/meshviewer/graph.go +++ b/meshviewer/graph.go @@ -50,7 +50,9 @@ func BuildGraph(nodes *runtime.Nodes) *Graph { vpn: make(map[string]interface{}), } + nodes.RLock() builder.readNodes(nodes.List) + nodes.RUnlock() graph := &Graph{Version: 1} graph.Batadv.Directed = false diff --git a/runtime/stats.go b/runtime/stats.go index 423a5f9..a477303 100644 --- a/runtime/stats.go +++ b/runtime/stats.go @@ -23,7 +23,7 @@ func NewGlobalStats(nodes *Nodes) (result *GlobalStats) { Models: make(CounterMap), } - nodes.Lock() + nodes.RLock() for _, node := range nodes.List { if node.Online { result.Nodes++ @@ -42,7 +42,7 @@ func NewGlobalStats(nodes *Nodes) (result *GlobalStats) { } } } - nodes.Unlock() + nodes.RUnlock() return }