Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-09-08 16:51:32 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-09-08 16:51:32 +0300
commit97c57fe37a4abf05f1f7050577a2bfd758a2563f (patch)
treed8acd2a290c47fb3a7849791eccba106cb488f09 /hugolib
parenta8fad866713fc50441a1788416f5b66697e87a1c (diff)
Add missing read lock in getNodes
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/hugo_sites.go8
-rw-r--r--hugolib/node.go1
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)
})
}