shithub: hugo

Download patch

ref: 97c57fe37a4abf05f1f7050577a2bfd758a2563f
parent: a8fad866713fc50441a1788416f5b66697e87a1c
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Thu Sep 8 12:51:32 EDT 2016

Add missing read lock in getNodes

--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -42,7 +42,7 @@
 
 	// 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) 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
 		}
 	}
--- a/hugolib/node.go
+++ b/hugolib/node.go
@@ -288,7 +288,6 @@
 func (n *Node) initTranslations() {
 	n.translationsInit.Do(func() {
 		n.translations = n.Site.owner.getNodes(n.nodeID)
-		//sort.Sort(n.translations)
 	})
 }
 
--