diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-09-08 16:51:32 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-09-08 16:51:32 +0300 |
commit | 97c57fe37a4abf05f1f7050577a2bfd758a2563f (patch) | |
tree | d8acd2a290c47fb3a7849791eccba106cb488f09 /hugolib | |
parent | a8fad866713fc50441a1788416f5b66697e87a1c (diff) |
Add missing read lock in getNodes
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/hugo_sites.go | 8 | ||||
-rw-r--r-- | hugolib/node.go | 1 |
2 files changed, 5 insertions, 4 deletions
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go index 36b797e7e..c0e077bd1 100644 --- a/hugolib/hugo_sites.go +++ b/hugolib/hugo_sites.go @@ -42,7 +42,7 @@ type HugoSites struct { // Maps internalID to a set of nodes. nodeMap map[string]Nodes - nodeMapMu sync.Mutex + nodeMapMu sync.RWMutex } // NewHugoSites creates a new collection of sites given the input sites, building @@ -108,9 +108,11 @@ func (h *HugoSites) addNode(nodeID string, node *Node) { } func (h *HugoSites) getNodes(nodeID string) Nodes { - // At this point it is read only, so no need to lock. if nodeID != "" { - if nodes, ok := h.nodeMap[nodeID]; ok { + h.nodeMapMu.RLock() + nodes, ok := h.nodeMap[nodeID] + h.nodeMapMu.RUnlock() + if ok { return nodes } } diff --git a/hugolib/node.go b/hugolib/node.go index 3b3d40394..566fd4799 100644 --- a/hugolib/node.go +++ b/hugolib/node.go @@ -288,7 +288,6 @@ func (n *Node) IsTranslated() bool { func (n *Node) initTranslations() { n.translationsInit.Do(func() { n.translations = n.Site.owner.getNodes(n.nodeID) - //sort.Sort(n.translations) }) } |