From 34a920e01f39a71e856ecbd9272e03de55cc313d Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Tue, 7 Mar 2017 18:02:32 +0100 Subject: [PATCH] [BUGFIX] mutex like it should be --- meshviewer/graph.go | 2 ++ runtime/stats.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) 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 }