correction + go deadlock
This commit is contained in:
parent
34a920e01f
commit
4628a8d5ab
@ -50,9 +50,7 @@ func BuildGraph(nodes *runtime.Nodes) *Graph {
|
||||
vpn: make(map[string]interface{}),
|
||||
}
|
||||
|
||||
nodes.RLock()
|
||||
builder.readNodes(nodes.List)
|
||||
nodes.RUnlock()
|
||||
builder.readNodes(nodes)
|
||||
|
||||
graph := &Graph{Version: 1}
|
||||
graph.Batadv.Directed = false
|
||||
@ -60,9 +58,12 @@ func BuildGraph(nodes *runtime.Nodes) *Graph {
|
||||
return graph
|
||||
}
|
||||
|
||||
func (builder *graphBuilder) readNodes(nodes map[string]*runtime.Node) {
|
||||
func (builder *graphBuilder) readNodes(nodes *runtime.Nodes) {
|
||||
nodes.RLock()
|
||||
defer nodes.RUnlock()
|
||||
|
||||
// Fill mac->id map
|
||||
for sourceID, node := range nodes {
|
||||
for sourceID, node := range nodes.List {
|
||||
if nodeinfo := node.Nodeinfo; nodeinfo != nil {
|
||||
// is VPN address?
|
||||
if nodeinfo.VPN {
|
||||
@ -93,7 +94,7 @@ func (builder *graphBuilder) readNodes(nodes map[string]*runtime.Node) {
|
||||
}
|
||||
|
||||
// Add links
|
||||
for sourceID, node := range nodes {
|
||||
for sourceID, node := range nodes.List {
|
||||
if node.Online {
|
||||
if neighbours := node.Neighbours; neighbours != nil {
|
||||
// Batman neighbours
|
||||
|
@ -4,9 +4,10 @@ import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
|
||||
"github.com/FreifunkBremen/yanic/data"
|
||||
"github.com/FreifunkBremen/yanic/jsontime"
|
||||
)
|
||||
@ -15,7 +16,7 @@ import (
|
||||
type Nodes struct {
|
||||
List map[string]*Node `json:"nodes"` // the current nodemap, indexed by node ID
|
||||
config *Config
|
||||
sync.RWMutex
|
||||
deadlock.RWMutex
|
||||
}
|
||||
|
||||
// NewNodes create Nodes structs
|
||||
|
Loading…
Reference in New Issue
Block a user