commit 97c57fe37a4abf05f1f7050577a2bfd758a2563f
parent a8fad866713fc50441a1788416f5b66697e87a1c
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Thu, 8 Sep 2016 16:51:32 +0300
Add missing read lock in getNodes
Diffstat:
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git 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
@@ -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)
})
}